Blame SOURCES/kvm-qemu-nbd-Enhance-man-page.patch

7711c0
From 649cb3fdd8a60caa687452be84fb06de78fead9b Mon Sep 17 00:00:00 2001
7711c0
From: John Snow <jsnow@redhat.com>
7711c0
Date: Wed, 27 Mar 2019 17:22:37 +0100
7711c0
Subject: [PATCH 099/163] qemu-nbd: Enhance man page
7711c0
7711c0
RH-Author: John Snow <jsnow@redhat.com>
7711c0
Message-id: <20190327172308.31077-25-jsnow@redhat.com>
7711c0
Patchwork-id: 85186
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 24/55] qemu-nbd: Enhance man page
7711c0
Bugzilla: 1691009
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
7711c0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
7711c0
From: Eric Blake <eblake@redhat.com>
7711c0
7711c0
Document some useful qemu-nbd command lines. Mention some restrictions
7711c0
on particular options, like -p being only for MBR images, or -c/-d
7711c0
being Linux-only.  Update some text given the recent change to no
7711c0
longer serve oldstyle protocol (missed in commit 7f7dfe2a).  Also,
7711c0
consistently use trailing '.' in describing options.
7711c0
7711c0
Signed-off-by: Eric Blake <eblake@redhat.com>
7711c0
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
7711c0
Message-Id: <20190117193658.16413-4-eblake@redhat.com>
7711c0
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7711c0
(cherry picked from commit 86b7f6771f0cd1552791d1bfc2bdebd65cf967a3)
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 qemu-nbd.texi | 94 +++++++++++++++++++++++++++++++++++++++++++++++------------
7711c0
 1 file changed, 75 insertions(+), 19 deletions(-)
7711c0
7711c0
diff --git a/qemu-nbd.texi b/qemu-nbd.texi
7711c0
index 96b1546..f218291 100644
7711c0
--- a/qemu-nbd.texi
7711c0
+++ b/qemu-nbd.texi
7711c0
@@ -10,11 +10,17 @@
7711c0
 
7711c0
 Export a QEMU disk image using the NBD protocol.
7711c0
 
7711c0
+Other uses:
7711c0
+@itemize
7711c0
+@item
7711c0
+Bind a /dev/nbdX block device to a QEMU server (on Linux).
7711c0
+@end itemize
7711c0
+
7711c0
 @c man end
7711c0
 
7711c0
 @c man begin OPTIONS
7711c0
 @var{filename} is a disk image filename, or a set of block
7711c0
-driver options if @var{--image-opts} is specified.
7711c0
+driver options if @option{--image-opts} is specified.
7711c0
 
7711c0
 @var{dev} is an NBD device.
7711c0
 
7711c0
@@ -27,24 +33,25 @@ supported. The common object types that it makes sense to define are the
7711c0
 keys, and the @code{tls-creds} object, which is used to supply TLS
7711c0
 credentials for the qemu-nbd server.
7711c0
 @item -p, --port=@var{port}
7711c0
-The TCP port to listen on (default @samp{10809})
7711c0
+The TCP port to listen on (default @samp{10809}).
7711c0
 @item -o, --offset=@var{offset}
7711c0
-The offset into the image
7711c0
+The offset into the image.
7711c0
 @item -b, --bind=@var{iface}
7711c0
-The interface to bind to (default @samp{0.0.0.0})
7711c0
+The interface to bind to (default @samp{0.0.0.0}).
7711c0
 @item -k, --socket=@var{path}
7711c0
-Use a unix socket with path @var{path}
7711c0
+Use a unix socket with path @var{path}.
7711c0
 @item --image-opts
7711c0
 Treat @var{filename} as a set of image options, instead of a plain
7711c0
 filename. If this flag is specified, the @var{-f} flag should
7711c0
 not be used, instead the '@code{format=}' option should be set.
7711c0
 @item -f, --format=@var{fmt}
7711c0
 Force the use of the block driver for format @var{fmt} instead of
7711c0
-auto-detecting
7711c0
+auto-detecting.
7711c0
 @item -r, --read-only
7711c0
-Export the disk as read-only
7711c0
+Export the disk as read-only.
7711c0
 @item -P, --partition=@var{num}
7711c0
-Only expose partition @var{num}
7711c0
+Only expose MBR partition @var{num}.  Understands physical partitions
7711c0
+1-4 and logical partitions 5-8.
7711c0
 @item -B, --bitmap=@var{name}
7711c0
 If @var{filename} has a qcow2 persistent bitmap @var{name}, expose
7711c0
 that bitmap via the ``qemu:dirty-bitmap:@var{name}'' context
7711c0
@@ -52,7 +59,7 @@ accessible through NBD_OPT_SET_META_CONTEXT.
7711c0
 @item -s, --snapshot
7711c0
 Use @var{filename} as an external snapshot, create a temporary
7711c0
 file with backing_file=@var{filename}, redirect the write to
7711c0
-the temporary one
7711c0
+the temporary one.
7711c0
 @item -l, --load-snapshot=@var{snapshot_param}
7711c0
 Load an internal snapshot inside @var{filename} and export it
7711c0
 as an read-only device, @var{snapshot_param} format is
7711c0
@@ -76,19 +83,20 @@ driver-specific optimized zero write commands.  @var{detect-zeroes} is one of
7711c0
 converts a zero write to an unmap operation and can only be used if
7711c0
 @var{discard} is set to @samp{unmap}.  The default is @samp{off}.
7711c0
 @item -c, --connect=@var{dev}
7711c0
-Connect @var{filename} to NBD device @var{dev}
7711c0
+Connect @var{filename} to NBD device @var{dev} (Linux only).
7711c0
 @item -d, --disconnect
7711c0
-Disconnect the device @var{dev}
7711c0
+Disconnect the device @var{dev} (Linux only).
7711c0
 @item -e, --shared=@var{num}
7711c0
-Allow up to @var{num} clients to share the device (default @samp{1})
7711c0
+Allow up to @var{num} clients to share the device (default
7711c0
+@samp{1}). Safe for readers, but for now, consistency is not
7711c0
+guaranteed between multiple writers.
7711c0
 @item -t, --persistent
7711c0
-Don't exit on the last connection
7711c0
+Don't exit on the last connection.
7711c0
 @item -x, --export-name=@var{name}
7711c0
-Set the NBD volume export name. This switches the server to use
7711c0
-the new style NBD protocol negotiation
7711c0
+Set the NBD volume export name (default of a zero-length string).
7711c0
 @item -D, --description=@var{description}
7711c0
 Set the NBD volume export description, as a human-readable
7711c0
-string. Requires the use of @option{-x}
7711c0
+string.
7711c0
 @item --tls-creds=ID
7711c0
 Enable mandatory TLS encryption for the server by setting the ID
7711c0
 of the TLS credentials object previously created with the --object
7711c0
@@ -96,11 +104,11 @@ option.
7711c0
 @item --fork
7711c0
 Fork off the server process and exit the parent once the server is running.
7711c0
 @item -v, --verbose
7711c0
-Display extra debugging information
7711c0
+Display extra debugging information.
7711c0
 @item -h, --help
7711c0
-Display this help and exit
7711c0
+Display this help and exit.
7711c0
 @item -V, --version
7711c0
-Display version information and exit
7711c0
+Display version information and exit.
7711c0
 @item -T, --trace [[enable=]@var{pattern}][,events=@var{file}][,file=@var{file}]
7711c0
 @findex --trace
7711c0
 @include qemu-option-trace.texi
7711c0
@@ -108,6 +116,54 @@ Display version information and exit
7711c0
 
7711c0
 @c man end
7711c0
 
7711c0
+@c man begin EXAMPLES
7711c0
+Start a server listening on port 10809 that exposes only the
7711c0
+guest-visible contents of a qcow2 file, with no TLS encryption, and
7711c0
+with the default export name (an empty string). The command is
7711c0
+one-shot, and will block until the first successful client
7711c0
+disconnects:
7711c0
+
7711c0
+@example
7711c0
+qemu-nbd -f qcow2 file.qcow2
7711c0
+@end example
7711c0
+
7711c0
+Start a long-running server listening with encryption on port 10810,
7711c0
+and require clients to have a correct X.509 certificate to connect to
7711c0
+a 1 megabyte subset of a raw file, using the export name 'subset':
7711c0
+
7711c0
+@example
7711c0
+qemu-nbd \
7711c0
+  --object tls-creds-x509,id=tls0,endpoint=server,dir=/path/to/qemutls \
7711c0
+  --tls-creds tls0 -t -x subset -p 10810 \
7711c0
+  --image-opts driver=raw,offset=1M,size=1M,file.driver=file,file.filename=file.raw
7711c0
+@end example
7711c0
+
7711c0
+Serve a read-only copy of just the first MBR partition of a guest
7711c0
+image over a Unix socket with as many as 5 simultaneous readers, with
7711c0
+a persistent process forked as a daemon:
7711c0
+
7711c0
+@example
7711c0
+qemu-nbd --fork --persistent --shared=5 --socket=/path/to/sock \
7711c0
+  --partition=1 --read-only --format=qcow2 file.qcow2
7711c0
+@end example
7711c0
+
7711c0
+Expose the guest-visible contents of a qcow2 file via a block device
7711c0
+/dev/nbd0 (and possibly creating /dev/nbd0p1 and friends for
7711c0
+partitions found within), then disconnect the device when done.
7711c0
+Access to bind qemu-nbd to an /dev/nbd device generally requires root
7711c0
+privileges, and may also require the execution of @code{modprobe nbd}
7711c0
+to enable the kernel NBD client module.  @emph{CAUTION}: Do not use
7711c0
+this method to mount filesystems from an untrusted guest image - a
7711c0
+malicious guest may have prepared the image to attempt to trigger
7711c0
+kernel bugs in partition probing or file system mounting.
7711c0
+
7711c0
+@example
7711c0
+qemu-nbd -c /dev/nbd0 -f qcow2 file.qcow2
7711c0
+qemu-nbd -d /dev/nbd0
7711c0
+@end example
7711c0
+
7711c0
+@c man end
7711c0
+
7711c0
 @ignore
7711c0
 
7711c0
 @setfilename qemu-nbd
7711c0
-- 
7711c0
1.8.3.1
7711c0