|
|
7711c0 |
From f9d66802239e15434d7d0c01a8bc11afb2708a75 Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Date: Wed, 27 Mar 2019 17:22:56 +0100
|
|
|
7711c0 |
Subject: [PATCH 118/163] qemu-nbd: Deprecate qemu-nbd --partition
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Message-id: <20190327172308.31077-44-jsnow@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 85223
|
|
|
7711c0 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 43/55] qemu-nbd: Deprecate qemu-nbd --partition
|
|
|
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 |
The existing qemu-nbd --partition code claims to handle logical
|
|
|
7711c0 |
partitions up to 8, since its introduction in 2008 (commit 7a5ca86).
|
|
|
7711c0 |
However, the implementation is bogus (actual MBR logical partitions
|
|
|
7711c0 |
form a sort of linked list, with one partition per extended table
|
|
|
7711c0 |
entry, rather than four logical partitions in a single extended
|
|
|
7711c0 |
table), making the code unlikely to work for anything beyond -P5 on
|
|
|
7711c0 |
actual guest images. What's more, the code does not support GPT
|
|
|
7711c0 |
partitions, which are becoming more popular, and maintaining device
|
|
|
7711c0 |
subsetting in both NBD and the raw device is unnecessary duplication
|
|
|
7711c0 |
of effort (even if it is not too difficult).
|
|
|
7711c0 |
|
|
|
7711c0 |
Note that obtaining the offsets of a partition (MBR or GPT) can be
|
|
|
7711c0 |
learned by using 'qemu-nbd -c /dev/nbd0 file.qcow2 && sfdisk --dump
|
|
|
7711c0 |
/dev/nbd0', but by the time you've done that, you might as well
|
|
|
7711c0 |
just mount /dev/nbd0p1 that the kernel creates for you instead of
|
|
|
7711c0 |
bothering with qemu exporting a subset. Or, keeping to just
|
|
|
7711c0 |
user-space code, use nbdkit's partition filter, which has already
|
|
|
7711c0 |
known both GPT and primary MBR partitions for a while, and was
|
|
|
7711c0 |
just recently enhanced to support arbitrary logical MBR parititions.
|
|
|
7711c0 |
|
|
|
7711c0 |
Start the clock on the deprecation cycle, with examples of how
|
|
|
7711c0 |
to accomplish device subsetting without using -P.
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
Message-Id: <20190125234837.2272-1-eblake@redhat.com>
|
|
|
7711c0 |
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
7711c0 |
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
7711c0 |
(cherry picked from commit 0ae2d54645eb2888af6dc7f701bc02ca18e4e656)
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
qemu-doc.texi | 33 +++++++++++++++++++++++++++++++++
|
|
|
7711c0 |
qemu-nbd.c | 2 ++
|
|
|
7711c0 |
qemu-nbd.texi | 6 ++++--
|
|
|
7711c0 |
3 files changed, 39 insertions(+), 2 deletions(-)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/qemu-doc.texi b/qemu-doc.texi
|
|
|
7711c0 |
index 88358be..2acbec5 100644
|
|
|
7711c0 |
--- a/qemu-doc.texi
|
|
|
7711c0 |
+++ b/qemu-doc.texi
|
|
|
7711c0 |
@@ -2987,6 +2987,39 @@ The ``xlnx-zcu102'' machine has the same features and capabilites in QEMU.
|
|
|
7711c0 |
In order to prevent QEMU from automatically opening an image's backing
|
|
|
7711c0 |
chain, use ``"backing": null'' instead.
|
|
|
7711c0 |
|
|
|
7711c0 |
+@section Related binaries
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+@subsection qemu-nbd --partition (since 4.0.0)
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+The ``qemu-nbd --partition $digit'' code (also spelled @option{-P})
|
|
|
7711c0 |
+can only handle MBR partitions, and has never correctly handled
|
|
|
7711c0 |
+logical partitions beyond partition 5. If you know the offset and
|
|
|
7711c0 |
+length of the partition (perhaps by using @code{sfdisk} within the
|
|
|
7711c0 |
+guest), you can achieve the effect of exporting just that subset of
|
|
|
7711c0 |
+the disk by use of the @option{--image-opts} option with a raw
|
|
|
7711c0 |
+blockdev using the @code{offset} and @code{size} parameters layered on
|
|
|
7711c0 |
+top of any other existing blockdev. For example, if partition 1 is
|
|
|
7711c0 |
+100MiB long starting at 1MiB, the old command:
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+@code{qemu-nbd -t -P 1 -f qcow2 file.qcow2}
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+can be rewritten as:
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+@code{qemu-nbd -t --image-opts driver=raw,offset=1M,size=100M,file.driver=qcow2,file.backing.driver=file,file.backing.filename=file.qcow2}
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+Alternatively, the @code{nbdkit} project provides a more powerful
|
|
|
7711c0 |
+partition filter on top of its nbd plugin, which can be used to select
|
|
|
7711c0 |
+an arbitrary MBR or GPT partition on top of any other full-image NBD
|
|
|
7711c0 |
+export. Using this to rewrite the above example results in:
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+@code{qemu-nbd -t -k /tmp/sock -f qcow2 file.qcow2 &}
|
|
|
7711c0 |
+@code{nbdkit -f --filter=partition nbd socket=/tmp/sock partition=1}
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+Note that if you are exposing the export via /dev/nbd0, it is easier
|
|
|
7711c0 |
+to just export the entire image and then mount only /dev/nbd0p1 than
|
|
|
7711c0 |
+it is to reinvoke @command{qemu-nbd -c /dev/nbd0} limited to just a
|
|
|
7711c0 |
+subset of the image.
|
|
|
7711c0 |
+
|
|
|
7711c0 |
@node License
|
|
|
7711c0 |
@appendix License
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/qemu-nbd.c b/qemu-nbd.c
|
|
|
7711c0 |
index 1f7b2a0..00c07fd 100644
|
|
|
7711c0 |
--- a/qemu-nbd.c
|
|
|
7711c0 |
+++ b/qemu-nbd.c
|
|
|
7711c0 |
@@ -787,6 +787,8 @@ int main(int argc, char **argv)
|
|
|
7711c0 |
flags &= ~BDRV_O_RDWR;
|
|
|
7711c0 |
break;
|
|
|
7711c0 |
case 'P':
|
|
|
7711c0 |
+ warn_report("The '-P' option is deprecated; use --image-opts with "
|
|
|
7711c0 |
+ "a raw device wrapper for subset exports instead");
|
|
|
7711c0 |
if (qemu_strtoi(optarg, NULL, 0, &partition) < 0 ||
|
|
|
7711c0 |
partition < 1 || partition > 8) {
|
|
|
7711c0 |
error_report("Invalid partition '%s'", optarg);
|
|
|
7711c0 |
diff --git a/qemu-nbd.texi b/qemu-nbd.texi
|
|
|
7711c0 |
index 386bece..d0c5182 100644
|
|
|
7711c0 |
--- a/qemu-nbd.texi
|
|
|
7711c0 |
+++ b/qemu-nbd.texi
|
|
|
7711c0 |
@@ -56,8 +56,10 @@ auto-detecting.
|
|
|
7711c0 |
@item -r, --read-only
|
|
|
7711c0 |
Export the disk as read-only.
|
|
|
7711c0 |
@item -P, --partition=@var{num}
|
|
|
7711c0 |
-Only expose MBR partition @var{num}. Understands physical partitions
|
|
|
7711c0 |
-1-4 and logical partitions 5-8.
|
|
|
7711c0 |
+Deprecated: Only expose MBR partition @var{num}. Understands physical
|
|
|
7711c0 |
+partitions 1-4 and logical partition 5. New code should instead use
|
|
|
7711c0 |
+@option{--image-opts} with the raw driver wrapping a subset of the
|
|
|
7711c0 |
+original image.
|
|
|
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 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|