]> git.proxmox.com Git - mirror_qemu.git/blame - qemu-nbd.texi
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
[mirror_qemu.git] / qemu-nbd.texi
CommitLineData
7a5ca864
FB
1@example
2@c man begin SYNOPSIS
7e8911bb
SW
3@command{qemu-nbd} [OPTION]... @var{filename}
4
68b96f15
EB
5@command{qemu-nbd} @option{-L} [OPTION]...
6
7e8911bb 7@command{qemu-nbd} @option{-d} @var{dev}
7a5ca864
FB
8@c man end
9@end example
10
11@c man begin DESCRIPTION
12
7e8911bb 13Export a QEMU disk image using the NBD protocol.
7a5ca864 14
86b7f677
EB
15Other uses:
16@itemize
17@item
18Bind a /dev/nbdX block device to a QEMU server (on Linux).
68b96f15
EB
19@item
20As a client to query exports of a remote NBD server.
86b7f677
EB
21@end itemize
22
7a5ca864
FB
23@c man end
24
25@c man begin OPTIONS
77c9aaef 26@var{filename} is a disk image filename, or a set of block
86b7f677 27driver options if @option{--image-opts} is specified.
7e8911bb
SW
28
29@var{dev} is an NBD device.
30
4a6b819c 31@table @option
0ab3b337
DB
32@item --object type,id=@var{id},...props...
33Define a new instance of the @var{type} object class identified by @var{id}.
34See the @code{qemu(1)} manual page for full details of the properties
145614a1 35supported. The common object types that it makes sense to define are the
0ab3b337 36@code{secret} object, which is used to supply passwords and/or encryption
145614a1 37keys, and the @code{tls-creds} object, which is used to supply TLS
68b96f15 38credentials for the qemu-nbd server or client.
4a6b819c 39@item -p, --port=@var{port}
68b96f15
EB
40The TCP port to listen on as a server, or connect to as a client
41(default @samp{10809}).
4a6b819c 42@item -o, --offset=@var{offset}
86b7f677 43The offset into the image.
4a6b819c 44@item -b, --bind=@var{iface}
68b96f15
EB
45The interface to bind to as a server, or connect to as a client
46(default @samp{0.0.0.0}).
4a6b819c 47@item -k, --socket=@var{path}
86b7f677 48Use a unix socket with path @var{path}.
77c9aaef
DB
49@item --image-opts
50Treat @var{filename} as a set of image options, instead of a plain
51filename. If this flag is specified, the @var{-f} flag should
52not be used, instead the '@code{format=}' option should be set.
7e8911bb 53@item -f, --format=@var{fmt}
50901218 54Force the use of the block driver for format @var{fmt} instead of
86b7f677 55auto-detecting.
7a5ca864 56@item -r, --read-only
86b7f677 57Export the disk as read-only.
4a6b819c 58@item -P, --partition=@var{num}
0ae2d546
EB
59Deprecated: Only expose MBR partition @var{num}. Understands physical
60partitions 1-4 and logical partition 5. New code should instead use
61@option{--image-opts} with the raw driver wrapping a subset of the
62original image.
636192c4
EB
63@item -B, --bitmap=@var{name}
64If @var{filename} has a qcow2 persistent bitmap @var{name}, expose
65that bitmap via the ``qemu:dirty-bitmap:@var{name}'' context
66accessible through NBD_OPT_SET_META_CONTEXT.
2f726488 67@item -s, --snapshot
50901218 68Use @var{filename} as an external snapshot, create a temporary
b9dbb617 69file with backing_file=@var{filename}, redirect the write to
86b7f677 70the temporary one.
8c116b0e 71@item -l, --load-snapshot=@var{snapshot_param}
50901218 72Load an internal snapshot inside @var{filename} and export it
b9dbb617
SW
73as an read-only device, @var{snapshot_param} format is
74'snapshot.id=[ID],snapshot.name=[NAME]' or '[ID_OR_NAME]'
2f726488 75@item -n, --nocache
0eb256a2 76@itemx --cache=@var{cache}
50901218 77The cache mode to be used with the file. See the documentation of
b9dbb617 78the emulator's @code{-drive cache=...} option for allowed values.
0eb256a2 79@item --aio=@var{aio}
50901218 80Set the asynchronous I/O mode between @samp{threads} (the default)
b9dbb617 81and @samp{native} (Linux only).
ded9d2d5 82@item --discard=@var{discard}
50901218 83Control whether @dfn{discard} (also known as @dfn{trim} or @dfn{unmap})
7e8911bb
SW
84requests are ignored or passed to the filesystem. @var{discard} is one of
85@samp{ignore} (or @samp{off}), @samp{unmap} (or @samp{on}). The default is
86@samp{ignore}.
87@item --detect-zeroes=@var{detect-zeroes}
50901218 88Control the automatic conversion of plain zero writes by the OS to
7e8911bb
SW
89driver-specific optimized zero write commands. @var{detect-zeroes} is one of
90@samp{off}, @samp{on} or @samp{unmap}. @samp{unmap}
91converts a zero write to an unmap operation and can only be used if
92@var{discard} is set to @samp{unmap}. The default is @samp{off}.
bba7be96 93@item -c, --connect=@var{dev}
86b7f677 94Connect @var{filename} to NBD device @var{dev} (Linux only).
cd831bd7 95@item -d, --disconnect
86b7f677 96Disconnect the device @var{dev} (Linux only).
4a6b819c 97@item -e, --shared=@var{num}
86b7f677
EB
98Allow up to @var{num} clients to share the device (default
99@samp{1}). Safe for readers, but for now, consistency is not
100guaranteed between multiple writers.
75818250 101@item -t, --persistent
86b7f677 102Don't exit on the last connection.
b1a75b33 103@item -x, --export-name=@var{name}
86b7f677 104Set the NBD volume export name (default of a zero-length string).
b1a75b33
EB
105@item -D, --description=@var{description}
106Set the NBD volume export description, as a human-readable
86b7f677 107string.
68b96f15
EB
108@item -L, --list
109Connect as a client and list all details about the exports exposed by
110a remote NBD server. This enables list mode, and is incompatible
111with options that change behavior related to a specific export (such as
112@option{--export-name}, @option{--offset}, ...).
145614a1
DB
113@item --tls-creds=ID
114Enable mandatory TLS encryption for the server by setting the ID
115of the TLS credentials object previously created with the --object
68b96f15
EB
116option; or provide the credentials needed for connecting as a client
117in list mode.
ffb31e1d
HR
118@item --fork
119Fork off the server process and exit the parent once the server is running.
637bc5a5
HR
120@item --pid-file=PATH
121Store the server's process ID in the given file.
b25e12da
DB
122@item --tls-authz=ID
123Specify the ID of a qauthz object previously created with the
124--object option. This will be used to authorize connecting users
125against their x509 distinguished name.
7a5ca864 126@item -v, --verbose
86b7f677 127Display extra debugging information.
7a5ca864 128@item -h, --help
86b7f677 129Display this help and exit.
7a5ca864 130@item -V, --version
86b7f677 131Display version information and exit.
39ca463e
DL
132@item -T, --trace [[enable=]@var{pattern}][,events=@var{file}][,file=@var{file}]
133@findex --trace
134@include qemu-option-trace.texi
7a5ca864
FB
135@end table
136
137@c man end
138
86b7f677
EB
139@c man begin EXAMPLES
140Start a server listening on port 10809 that exposes only the
141guest-visible contents of a qcow2 file, with no TLS encryption, and
142with the default export name (an empty string). The command is
143one-shot, and will block until the first successful client
144disconnects:
145
146@example
147qemu-nbd -f qcow2 file.qcow2
148@end example
149
150Start a long-running server listening with encryption on port 10810,
b25e12da 151and whitelist clients with a specific X.509 certificate to connect to
86b7f677
EB
152a 1 megabyte subset of a raw file, using the export name 'subset':
153
154@example
155qemu-nbd \
156 --object tls-creds-x509,id=tls0,endpoint=server,dir=/path/to/qemutls \
b25e12da
DB
157 --object 'authz-simple,id=auth0,identity=CN=laptop.example.com,,\
158 O=Example Org,,L=London,,ST=London,,C=GB' \
159 --tls-creds tls0 --tls-authz auth0 \
160 -t -x subset -p 10810 \
86b7f677
EB
161 --image-opts driver=raw,offset=1M,size=1M,file.driver=file,file.filename=file.raw
162@end example
163
164Serve a read-only copy of just the first MBR partition of a guest
165image over a Unix socket with as many as 5 simultaneous readers, with
166a persistent process forked as a daemon:
167
168@example
169qemu-nbd --fork --persistent --shared=5 --socket=/path/to/sock \
170 --partition=1 --read-only --format=qcow2 file.qcow2
171@end example
172
173Expose the guest-visible contents of a qcow2 file via a block device
174/dev/nbd0 (and possibly creating /dev/nbd0p1 and friends for
175partitions found within), then disconnect the device when done.
176Access to bind qemu-nbd to an /dev/nbd device generally requires root
177privileges, and may also require the execution of @code{modprobe nbd}
178to enable the kernel NBD client module. @emph{CAUTION}: Do not use
179this method to mount filesystems from an untrusted guest image - a
180malicious guest may have prepared the image to attempt to trigger
181kernel bugs in partition probing or file system mounting.
182
183@example
184qemu-nbd -c /dev/nbd0 -f qcow2 file.qcow2
185qemu-nbd -d /dev/nbd0
186@end example
187
68b96f15
EB
188Query a remote server to see details about what export(s) it is
189serving on port 10809, and authenticating via PSK:
190
191@example
192qemu-nbd \
193 --object tls-creds-psk,id=tls0,dir=/tmp/keys,username=eblake,endpoint=client \
194 --tls-creds tls0 -L -b remote.example.com
195@end example
196
86b7f677
EB
197@c man end
198
7a5ca864
FB
199@ignore
200
201@setfilename qemu-nbd
202@settitle QEMU Disk Network Block Device Server
203
204@c man begin AUTHOR
205Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>.
206This is free software; see the source for copying conditions. There is NO
207warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
208@c man end
209
210@c man begin SEEALSO
7e8911bb 211qemu(1), qemu-img(1)
7a5ca864
FB
212@c man end
213
214@end ignore