]> git.proxmox.com Git - mirror_qemu.git/blame - qemu-nbd.texi
test-filter-mirror: pass UNIX domain socket through fd
[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}
86b7f677
EB
59Only expose MBR partition @var{num}. Understands physical partitions
601-4 and logical partitions 5-8.
636192c4
EB
61@item -B, --bitmap=@var{name}
62If @var{filename} has a qcow2 persistent bitmap @var{name}, expose
63that bitmap via the ``qemu:dirty-bitmap:@var{name}'' context
64accessible through NBD_OPT_SET_META_CONTEXT.
2f726488 65@item -s, --snapshot
50901218 66Use @var{filename} as an external snapshot, create a temporary
b9dbb617 67file with backing_file=@var{filename}, redirect the write to
86b7f677 68the temporary one.
8c116b0e 69@item -l, --load-snapshot=@var{snapshot_param}
50901218 70Load an internal snapshot inside @var{filename} and export it
b9dbb617
SW
71as an read-only device, @var{snapshot_param} format is
72'snapshot.id=[ID],snapshot.name=[NAME]' or '[ID_OR_NAME]'
2f726488 73@item -n, --nocache
0eb256a2 74@itemx --cache=@var{cache}
50901218 75The cache mode to be used with the file. See the documentation of
b9dbb617 76the emulator's @code{-drive cache=...} option for allowed values.
0eb256a2 77@item --aio=@var{aio}
50901218 78Set the asynchronous I/O mode between @samp{threads} (the default)
b9dbb617 79and @samp{native} (Linux only).
ded9d2d5 80@item --discard=@var{discard}
50901218 81Control whether @dfn{discard} (also known as @dfn{trim} or @dfn{unmap})
7e8911bb
SW
82requests are ignored or passed to the filesystem. @var{discard} is one of
83@samp{ignore} (or @samp{off}), @samp{unmap} (or @samp{on}). The default is
84@samp{ignore}.
85@item --detect-zeroes=@var{detect-zeroes}
50901218 86Control the automatic conversion of plain zero writes by the OS to
7e8911bb
SW
87driver-specific optimized zero write commands. @var{detect-zeroes} is one of
88@samp{off}, @samp{on} or @samp{unmap}. @samp{unmap}
89converts a zero write to an unmap operation and can only be used if
90@var{discard} is set to @samp{unmap}. The default is @samp{off}.
bba7be96 91@item -c, --connect=@var{dev}
86b7f677 92Connect @var{filename} to NBD device @var{dev} (Linux only).
cd831bd7 93@item -d, --disconnect
86b7f677 94Disconnect the device @var{dev} (Linux only).
4a6b819c 95@item -e, --shared=@var{num}
86b7f677
EB
96Allow up to @var{num} clients to share the device (default
97@samp{1}). Safe for readers, but for now, consistency is not
98guaranteed between multiple writers.
75818250 99@item -t, --persistent
86b7f677 100Don't exit on the last connection.
b1a75b33 101@item -x, --export-name=@var{name}
86b7f677 102Set the NBD volume export name (default of a zero-length string).
b1a75b33
EB
103@item -D, --description=@var{description}
104Set the NBD volume export description, as a human-readable
86b7f677 105string.
68b96f15
EB
106@item -L, --list
107Connect as a client and list all details about the exports exposed by
108a remote NBD server. This enables list mode, and is incompatible
109with options that change behavior related to a specific export (such as
110@option{--export-name}, @option{--offset}, ...).
145614a1
DB
111@item --tls-creds=ID
112Enable mandatory TLS encryption for the server by setting the ID
113of the TLS credentials object previously created with the --object
68b96f15
EB
114option; or provide the credentials needed for connecting as a client
115in list mode.
ffb31e1d
HR
116@item --fork
117Fork off the server process and exit the parent once the server is running.
7a5ca864 118@item -v, --verbose
86b7f677 119Display extra debugging information.
7a5ca864 120@item -h, --help
86b7f677 121Display this help and exit.
7a5ca864 122@item -V, --version
86b7f677 123Display version information and exit.
39ca463e
DL
124@item -T, --trace [[enable=]@var{pattern}][,events=@var{file}][,file=@var{file}]
125@findex --trace
126@include qemu-option-trace.texi
7a5ca864
FB
127@end table
128
129@c man end
130
86b7f677
EB
131@c man begin EXAMPLES
132Start a server listening on port 10809 that exposes only the
133guest-visible contents of a qcow2 file, with no TLS encryption, and
134with the default export name (an empty string). The command is
135one-shot, and will block until the first successful client
136disconnects:
137
138@example
139qemu-nbd -f qcow2 file.qcow2
140@end example
141
142Start a long-running server listening with encryption on port 10810,
143and require clients to have a correct X.509 certificate to connect to
144a 1 megabyte subset of a raw file, using the export name 'subset':
145
146@example
147qemu-nbd \
148 --object tls-creds-x509,id=tls0,endpoint=server,dir=/path/to/qemutls \
149 --tls-creds tls0 -t -x subset -p 10810 \
150 --image-opts driver=raw,offset=1M,size=1M,file.driver=file,file.filename=file.raw
151@end example
152
153Serve a read-only copy of just the first MBR partition of a guest
154image over a Unix socket with as many as 5 simultaneous readers, with
155a persistent process forked as a daemon:
156
157@example
158qemu-nbd --fork --persistent --shared=5 --socket=/path/to/sock \
159 --partition=1 --read-only --format=qcow2 file.qcow2
160@end example
161
162Expose the guest-visible contents of a qcow2 file via a block device
163/dev/nbd0 (and possibly creating /dev/nbd0p1 and friends for
164partitions found within), then disconnect the device when done.
165Access to bind qemu-nbd to an /dev/nbd device generally requires root
166privileges, and may also require the execution of @code{modprobe nbd}
167to enable the kernel NBD client module. @emph{CAUTION}: Do not use
168this method to mount filesystems from an untrusted guest image - a
169malicious guest may have prepared the image to attempt to trigger
170kernel bugs in partition probing or file system mounting.
171
172@example
173qemu-nbd -c /dev/nbd0 -f qcow2 file.qcow2
174qemu-nbd -d /dev/nbd0
175@end example
176
68b96f15
EB
177Query a remote server to see details about what export(s) it is
178serving on port 10809, and authenticating via PSK:
179
180@example
181qemu-nbd \
182 --object tls-creds-psk,id=tls0,dir=/tmp/keys,username=eblake,endpoint=client \
183 --tls-creds tls0 -L -b remote.example.com
184@end example
185
86b7f677
EB
186@c man end
187
7a5ca864
FB
188@ignore
189
190@setfilename qemu-nbd
191@settitle QEMU Disk Network Block Device Server
192
193@c man begin AUTHOR
194Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>.
195This is free software; see the source for copying conditions. There is NO
196warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
197@c man end
198
199@c man begin SEEALSO
7e8911bb 200qemu(1), qemu-img(1)
7a5ca864
FB
201@c man end
202
203@end ignore