blob: f218291bf30d9410792f6ef4f36a3103508223bc [file] [log] [blame]
bellard7a5ca862008-05-27 21:13:40 +00001@example
2@c man begin SYNOPSIS
Sitsofe Wheeler7e8911b2016-01-05 07:33:31 +00003@command{qemu-nbd} [OPTION]... @var{filename}
4
5@command{qemu-nbd} @option{-d} @var{dev}
bellard7a5ca862008-05-27 21:13:40 +00006@c man end
7@end example
8
9@c man begin DESCRIPTION
10
Sitsofe Wheeler7e8911b2016-01-05 07:33:31 +000011Export a QEMU disk image using the NBD protocol.
bellard7a5ca862008-05-27 21:13:40 +000012
Eric Blake86b7f672019-01-17 13:36:40 -060013Other uses:
14@itemize
15@item
16Bind a /dev/nbdX block device to a QEMU server (on Linux).
17@end itemize
18
bellard7a5ca862008-05-27 21:13:40 +000019@c man end
20
21@c man begin OPTIONS
Daniel P. Berrange77c9aae2016-02-17 10:10:19 +000022@var{filename} is a disk image filename, or a set of block
Eric Blake86b7f672019-01-17 13:36:40 -060023driver options if @option{--image-opts} is specified.
Sitsofe Wheeler7e8911b2016-01-05 07:33:31 +000024
25@var{dev} is an NBD device.
26
aliguori4a6b8192008-09-22 20:41:57 +000027@table @option
Daniel P. Berrange0ab3b332016-02-10 18:41:00 +000028@item --object type,id=@var{id},...props...
29Define a new instance of the @var{type} object class identified by @var{id}.
30See the @code{qemu(1)} manual page for full details of the properties
Daniel P. Berrange145614a2016-02-10 18:41:13 +000031supported. The common object types that it makes sense to define are the
Daniel P. Berrange0ab3b332016-02-10 18:41:00 +000032@code{secret} object, which is used to supply passwords and/or encryption
Daniel P. Berrange145614a2016-02-10 18:41:13 +000033keys, and the @code{tls-creds} object, which is used to supply TLS
34credentials for the qemu-nbd server.
aliguori4a6b8192008-09-22 20:41:57 +000035@item -p, --port=@var{port}
Eric Blake86b7f672019-01-17 13:36:40 -060036The TCP port to listen on (default @samp{10809}).
aliguori4a6b8192008-09-22 20:41:57 +000037@item -o, --offset=@var{offset}
Eric Blake86b7f672019-01-17 13:36:40 -060038The offset into the image.
aliguori4a6b8192008-09-22 20:41:57 +000039@item -b, --bind=@var{iface}
Eric Blake86b7f672019-01-17 13:36:40 -060040The interface to bind to (default @samp{0.0.0.0}).
aliguori4a6b8192008-09-22 20:41:57 +000041@item -k, --socket=@var{path}
Eric Blake86b7f672019-01-17 13:36:40 -060042Use a unix socket with path @var{path}.
Daniel P. Berrange77c9aae2016-02-17 10:10:19 +000043@item --image-opts
44Treat @var{filename} as a set of image options, instead of a plain
45filename. If this flag is specified, the @var{-f} flag should
46not be used, instead the '@code{format=}' option should be set.
Sitsofe Wheeler7e8911b2016-01-05 07:33:31 +000047@item -f, --format=@var{fmt}
Sitsofe Wheeler50901212016-01-05 07:33:32 +000048Force the use of the block driver for format @var{fmt} instead of
Eric Blake86b7f672019-01-17 13:36:40 -060049auto-detecting.
bellard7a5ca862008-05-27 21:13:40 +000050@item -r, --read-only
Eric Blake86b7f672019-01-17 13:36:40 -060051Export the disk as read-only.
aliguori4a6b8192008-09-22 20:41:57 +000052@item -P, --partition=@var{num}
Eric Blake86b7f672019-01-17 13:36:40 -060053Only expose MBR partition @var{num}. Understands physical partitions
541-4 and logical partitions 5-8.
Eric Blake636192c2019-01-11 13:47:20 -060055@item -B, --bitmap=@var{name}
56If @var{filename} has a qcow2 persistent bitmap @var{name}, expose
57that bitmap via the ``qemu:dirty-bitmap:@var{name}'' context
58accessible through NBD_OPT_SET_META_CONTEXT.
ths2f726482008-07-03 11:47:46 +000059@item -s, --snapshot
Sitsofe Wheeler50901212016-01-05 07:33:32 +000060Use @var{filename} as an external snapshot, create a temporary
Sitsofe Wheelerb9dbb612016-01-05 07:33:30 +000061file with backing_file=@var{filename}, redirect the write to
Eric Blake86b7f672019-01-17 13:36:40 -060062the temporary one.
Wenchao Xia8c116b02013-12-04 17:10:55 +080063@item -l, --load-snapshot=@var{snapshot_param}
Sitsofe Wheeler50901212016-01-05 07:33:32 +000064Load an internal snapshot inside @var{filename} and export it
Sitsofe Wheelerb9dbb612016-01-05 07:33:30 +000065as an read-only device, @var{snapshot_param} format is
66'snapshot.id=[ID],snapshot.name=[NAME]' or '[ID_OR_NAME]'
ths2f726482008-07-03 11:47:46 +000067@item -n, --nocache
Paolo Bonzini0eb256a2013-02-08 13:19:07 +010068@itemx --cache=@var{cache}
Sitsofe Wheeler50901212016-01-05 07:33:32 +000069The cache mode to be used with the file. See the documentation of
Sitsofe Wheelerb9dbb612016-01-05 07:33:30 +000070the emulator's @code{-drive cache=...} option for allowed values.
Paolo Bonzini0eb256a2013-02-08 13:19:07 +010071@item --aio=@var{aio}
Sitsofe Wheeler50901212016-01-05 07:33:32 +000072Set the asynchronous I/O mode between @samp{threads} (the default)
Sitsofe Wheelerb9dbb612016-01-05 07:33:30 +000073and @samp{native} (Linux only).
Paolo Bonzinided9d2d2013-02-08 14:06:13 +010074@item --discard=@var{discard}
Sitsofe Wheeler50901212016-01-05 07:33:32 +000075Control whether @dfn{discard} (also known as @dfn{trim} or @dfn{unmap})
Sitsofe Wheeler7e8911b2016-01-05 07:33:31 +000076requests are ignored or passed to the filesystem. @var{discard} is one of
77@samp{ignore} (or @samp{off}), @samp{unmap} (or @samp{on}). The default is
78@samp{ignore}.
79@item --detect-zeroes=@var{detect-zeroes}
Sitsofe Wheeler50901212016-01-05 07:33:32 +000080Control the automatic conversion of plain zero writes by the OS to
Sitsofe Wheeler7e8911b2016-01-05 07:33:31 +000081driver-specific optimized zero write commands. @var{detect-zeroes} is one of
82@samp{off}, @samp{on} or @samp{unmap}. @samp{unmap}
83converts a zero write to an unmap operation and can only be used if
84@var{discard} is set to @samp{unmap}. The default is @samp{off}.
Ryota Ozakibba7be92010-03-04 00:18:43 +090085@item -c, --connect=@var{dev}
Eric Blake86b7f672019-01-17 13:36:40 -060086Connect @var{filename} to NBD device @var{dev} (Linux only).
thscd831bd2008-07-03 10:23:51 +000087@item -d, --disconnect
Eric Blake86b7f672019-01-17 13:36:40 -060088Disconnect the device @var{dev} (Linux only).
aliguori4a6b8192008-09-22 20:41:57 +000089@item -e, --shared=@var{num}
Eric Blake86b7f672019-01-17 13:36:40 -060090Allow up to @var{num} clients to share the device (default
91@samp{1}). Safe for readers, but for now, consistency is not
92guaranteed between multiple writers.
ths75818252008-07-03 13:41:03 +000093@item -t, --persistent
Eric Blake86b7f672019-01-17 13:36:40 -060094Don't exit on the last connection.
Eric Blakeb1a75b32016-10-14 13:33:03 -050095@item -x, --export-name=@var{name}
Eric Blake86b7f672019-01-17 13:36:40 -060096Set the NBD volume export name (default of a zero-length string).
Eric Blakeb1a75b32016-10-14 13:33:03 -050097@item -D, --description=@var{description}
98Set the NBD volume export description, as a human-readable
Eric Blake86b7f672019-01-17 13:36:40 -060099string.
Daniel P. Berrange145614a2016-02-10 18:41:13 +0000100@item --tls-creds=ID
101Enable mandatory TLS encryption for the server by setting the ID
102of the TLS credentials object previously created with the --object
103option.
Max Reitzffb31e12016-09-28 22:46:42 +0200104@item --fork
105Fork off the server process and exit the parent once the server is running.
bellard7a5ca862008-05-27 21:13:40 +0000106@item -v, --verbose
Eric Blake86b7f672019-01-17 13:36:40 -0600107Display extra debugging information.
bellard7a5ca862008-05-27 21:13:40 +0000108@item -h, --help
Eric Blake86b7f672019-01-17 13:36:40 -0600109Display this help and exit.
bellard7a5ca862008-05-27 21:13:40 +0000110@item -V, --version
Eric Blake86b7f672019-01-17 13:36:40 -0600111Display version information and exit.
Denis V. Lunev39ca4632016-06-17 17:44:12 +0300112@item -T, --trace [[enable=]@var{pattern}][,events=@var{file}][,file=@var{file}]
113@findex --trace
114@include qemu-option-trace.texi
bellard7a5ca862008-05-27 21:13:40 +0000115@end table
116
117@c man end
118
Eric Blake86b7f672019-01-17 13:36:40 -0600119@c man begin EXAMPLES
120Start a server listening on port 10809 that exposes only the
121guest-visible contents of a qcow2 file, with no TLS encryption, and
122with the default export name (an empty string). The command is
123one-shot, and will block until the first successful client
124disconnects:
125
126@example
127qemu-nbd -f qcow2 file.qcow2
128@end example
129
130Start a long-running server listening with encryption on port 10810,
131and require clients to have a correct X.509 certificate to connect to
132a 1 megabyte subset of a raw file, using the export name 'subset':
133
134@example
135qemu-nbd \
136 --object tls-creds-x509,id=tls0,endpoint=server,dir=/path/to/qemutls \
137 --tls-creds tls0 -t -x subset -p 10810 \
138 --image-opts driver=raw,offset=1M,size=1M,file.driver=file,file.filename=file.raw
139@end example
140
141Serve a read-only copy of just the first MBR partition of a guest
142image over a Unix socket with as many as 5 simultaneous readers, with
143a persistent process forked as a daemon:
144
145@example
146qemu-nbd --fork --persistent --shared=5 --socket=/path/to/sock \
147 --partition=1 --read-only --format=qcow2 file.qcow2
148@end example
149
150Expose the guest-visible contents of a qcow2 file via a block device
151/dev/nbd0 (and possibly creating /dev/nbd0p1 and friends for
152partitions found within), then disconnect the device when done.
153Access to bind qemu-nbd to an /dev/nbd device generally requires root
154privileges, and may also require the execution of @code{modprobe nbd}
155to enable the kernel NBD client module. @emph{CAUTION}: Do not use
156this method to mount filesystems from an untrusted guest image - a
157malicious guest may have prepared the image to attempt to trigger
158kernel bugs in partition probing or file system mounting.
159
160@example
161qemu-nbd -c /dev/nbd0 -f qcow2 file.qcow2
162qemu-nbd -d /dev/nbd0
163@end example
164
165@c man end
166
bellard7a5ca862008-05-27 21:13:40 +0000167@ignore
168
169@setfilename qemu-nbd
170@settitle QEMU Disk Network Block Device Server
171
172@c man begin AUTHOR
173Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>.
174This is free software; see the source for copying conditions. There is NO
175warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
176@c man end
177
178@c man begin SEEALSO
Sitsofe Wheeler7e8911b2016-01-05 07:33:31 +0000179qemu(1), qemu-img(1)
bellard7a5ca862008-05-27 21:13:40 +0000180@c man end
181
182@end ignore