Skip to contentSkip to conversation

qemu-nbd: Removed deprecated --partition option

PATCH In review Eric Blake 3 participants 5 messages Jan 22, 2020 – Jan 23, 2020

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

PATCH 1/1 qemu-nbd: Removed deprecated --partition option

The option was deprecated in 4.0.0 (commit 0ae2d546); it's now been long enough with no complaints to follow through with that process.

---
 qemu-deprecated.texi |  49 ++++++----------
 qemu-nbd.c           | 133 +------------------------------------------
 qemu-nbd.texi        |  13 ++---
 3 files changed, 24 insertions(+), 171 deletions(-)
qemu-deprecated.texi +18 -31
index 8471eef9c22d..1b4c638db8e0 100644
@@ -304,37 +304,6 @@ The above, converted to the current supported format:
 
 @section Related binaries
 
-@subsection qemu-nbd --partition (since 4.0.0)
-
-The ``qemu-nbd --partition $digit'' code (also spelled @option{-P})
-can only handle MBR partitions, and has never correctly handled
-logical partitions beyond partition 5.  If you know the offset and
-length of the partition (perhaps by using @code{sfdisk} within the
-guest), you can achieve the effect of exporting just that subset of
-the disk by use of the @option{--image-opts} option with a raw
-blockdev using the @code{offset} and @code{size} parameters layered on
-top of any other existing blockdev. For example, if partition 1 is
-100MiB long starting at 1MiB, the old command:
-
-@code{qemu-nbd -t -P 1 -f qcow2 file.qcow2}
-
-can be rewritten as:
-
-@code{qemu-nbd -t --image-opts driver=raw,offset=1M,size=100M,file.driver=qcow2,file.backing.driver=file,file.backing.filename=file.qcow2}
-
-Alternatively, the @code{nbdkit} project provides a more powerful
-partition filter on top of its nbd plugin, which can be used to select
-an arbitrary MBR or GPT partition on top of any other full-image NBD
-export.  Using this to rewrite the above example results in:
-
-@code{qemu-nbd -t -k /tmp/sock -f qcow2 file.qcow2 &}
-@code{nbdkit -f --filter=partition nbd socket=/tmp/sock partition=1}
-
-Note that if you are exposing the export via /dev/nbd0, it is easier
-to just export the entire image and then mount only /dev/nbd0p1 than
-it is to reinvoke @command{qemu-nbd -c /dev/nbd0} limited to just a
-subset of the image.
-
 @subsection qemu-img convert -n -o (since 4.2.0)
 
 All options specified in @option{-o} are image creation options, so
@@ -383,3 +352,21 @@ trouble after a recent upgrade.
 
 The "autoload" parameter has been ignored since 2.12.0. All bitmaps
 are automatically loaded from qcow2 images.
+
+@section Related binaries
+
+@subsection qemu-nbd --partition (removed in 5.0.0)
+
+The ``qemu-nbd --partition $digit'' code (also spelled @option{-P})
+could only handle MBR partitions, and never correctly handled logical
+partitions beyond partition 5.  Exporting a partition can still be
+done by utilizing the @option{--image-opts} option with a raw blockdev
+using the @code{offset} and @code{size} parameters layered on top of
+any other existing blockdev. For example, if partition 1 is 100MiB
+long starting at 1MiB, the old command:
+
+@code{qemu-nbd -t -P 1 -f qcow2 file.qcow2}
+
+can be rewritten as:
+
+@code{qemu-nbd -t --image-opts driver=raw,offset=1M,size=100M,file.driver=qcow2,file.backing.driver=file,file.backing.filename=file.qcow2}
qemu-nbd.c +2 -131

181 lines not on this page · raw message

qemu-nbd.texi +4 -9
index 7f55657722bd..36f4188a3f27 100644
@@ -55,11 +55,6 @@ Force the use of the block driver for format @var{fmt} instead of
 auto-detecting.
 @item -r, --read-only
 Export the disk as read-only.
-@item -P, --partition=@var{num}
-Deprecated: Only expose MBR partition @var{num}.  Understands physical
-partitions 1-4 and logical partition 5. New code should instead use
-@option{--image-opts} with the raw driver wrapping a subset of the
-original image.
 @item -B, --bitmap=@var{name}
 If @var{filename} has a qcow2 persistent bitmap @var{name}, expose
 that bitmap via the ``qemu:dirty-bitmap:@var{name}'' context
@@ -161,13 +156,13 @@ qemu-nbd \
   --image-opts driver=raw,offset=1M,size=1M,file.driver=file,file.filename=file.raw
 @end example
 
-Serve a read-only copy of just the first MBR partition of a guest
-image over a Unix socket with as many as 5 simultaneous readers, with
-a persistent process forked as a daemon:
+Serve a read-only copy of a guest image over a Unix socket with as
+many as 5 simultaneous readers, with a persistent process forked as a
+daemon:
 
 @example
 qemu-nbd --fork --persistent --shared=5 --socket=/path/to/sock \
-  --partition=1 --read-only --format=qcow2 file.qcow2
+  --read-only --format=qcow2 file.qcow2
 @end example
 
 Expose the guest-visible contents of a qcow2 file via a block device
Signature · 1 line
2.24.1
#1 lore raw
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===

TEST check-qtest-aarch64: tests/qtest/boot-serial-test
TEST check-qtest-aarch64: tests/qtest/migration-test
**
ERROR:/tmp/qemu-test/src/tests/test-char.c:1125:char_serial_test: 'chr' should not be NULL
ERROR - Bail out! ERROR:/tmp/qemu-test/src/tests/test-char.c:1125:char_serial_test: 'chr' should not be NULL
make: *** [check-unit] Error 1
make: *** Waiting for unfinished jobs....
qemu-system-aarch64: -accel kvm: invalid accelerator kvm
qemu-system-aarch64: falling back to tcg
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=bcad5894bb1b43f2b125072f6631cf33', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-7pp43kkd/src/docker-src.2020-01-22-16.49.30.24833:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=bcad5894bb1b43f2b125072f6631cf33
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-7pp43kkd/src'
make: *** [docker-run-test-quick@centos7] Error 2

real 11m21.905s
user 0m8.570s

The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#2 lore raw
In reply to Eric Blake
Quoted 64 lines · Eric Blake

The option was deprecated in 4.0.0 (commit 0ae2d546); it's now been long enough with no complaints to follow through with that process.

---
 qemu-deprecated.texi |  49 ++++++----------
 qemu-nbd.c           | 133 +------------------------------------------
 qemu-nbd.texi        |  13 ++---
 3 files changed, 24 insertions(+), 171 deletions(-)
qemu-deprecated.texi +8 -31
index 8471eef9c22d..1b4c638db8e0 100644
@@ -304,37 +304,6 @@ The above, converted to the current supported format:
 
 @section Related binaries
 
-@subsection qemu-nbd --partition (since 4.0.0)
-
-The ``qemu-nbd --partition $digit'' code (also spelled @option{-P})
-can only handle MBR partitions, and has never correctly handled
-logical partitions beyond partition 5.  If you know the offset and
-length of the partition (perhaps by using @code{sfdisk} within the
-guest), you can achieve the effect of exporting just that subset of
-the disk by use of the @option{--image-opts} option with a raw
-blockdev using the @code{offset} and @code{size} parameters layered on
-top of any other existing blockdev. For example, if partition 1 is
-100MiB long starting at 1MiB, the old command:
-
-@code{qemu-nbd -t -P 1 -f qcow2 file.qcow2}
-
-can be rewritten as:
-
-@code{qemu-nbd -t --image-opts driver=raw,offset=1M,size=100M,file.driver=qcow2,file.backing.driver=file,file.backing.filename=file.qcow2}
-
-Alternatively, the @code{nbdkit} project provides a more powerful
-partition filter on top of its nbd plugin, which can be used to select
-an arbitrary MBR or GPT partition on top of any other full-image NBD
-export.  Using this to rewrite the above example results in:
-
-@code{qemu-nbd -t -k /tmp/sock -f qcow2 file.qcow2 &}
-@code{nbdkit -f --filter=partition nbd socket=/tmp/sock partition=1}
-
-Note that if you are exposing the export via /dev/nbd0, it is easier
-to just export the entire image and then mount only /dev/nbd0p1 than
-it is to reinvoke @command{qemu-nbd -c /dev/nbd0} limited to just a
-subset of the image.
-
 @subsection qemu-img convert -n -o (since 4.2.0)
 
 All options specified in @option{-o} are image creation options, so
@@ -383,3 +352,21 @@ trouble after a recent upgrade.
 
 The "autoload" parameter has been ignored since 2.12.0. All bitmaps
 are automatically loaded from qcow2 images.
+
+@section Related binaries
+
+@subsection qemu-nbd --partition (removed in 5.0.0)
+
+The ``qemu-nbd --partition $digit'' code (also spelled @option{-P})
+could only handle MBR partitions, and never correctly handled logical
+partitions beyond partition 5.  Exporting a partition can still be

qemu-deprecated.texi trouble after a recent upgrade. · line 372

Quoted 10 lines
qemu-deprecated.texi +10 -0
+done by utilizing the @option{--image-opts} option with a raw blockdev
+using the @code{offset} and @code{size} parameters layered on top of
+any other existing blockdev. For example, if partition 1 is 100MiB
+long starting at 1MiB, the old command:
+
+@code{qemu-nbd -t -P 1 -f qcow2 file.qcow2}
+
+can be rewritten as:
+
+@code{qemu-nbd -t --image-opts driver=raw,offset=1M,size=100M,file.driver=qcow2,file.backing.driver=file,file.backing.filename=file.qcow2}

I know you just moved it from above, but isn’t this wrong? Shouldn’t it be s/backing/file/g?

Max

author
#3 lore raw
Quoted 14 lines · Max Reitz
Quoted 12 lines · Eric Blake

The option was deprecated in 4.0.0 (commit 0ae2d546); it's now been long enough with no complaints to follow through with that process.

---

-@code{qemu-nbd -t -P 1 -f qcow2 file.qcow2}

qemu-deprecated.texi +0 -5
-
-can be rewritten as:
-
-@code{qemu-nbd -t --image-opts driver=raw,offset=1M,size=100M,file.driver=qcow2,file.backing.driver=file,file.backing.filename=file.qcow2}
-
Quoted 6 lines

qemu-deprecated.texi trouble after a recent upgrade. · line 372

Quoted 3 lines
qemu-deprecated.texi +3 -0
+can be rewritten as:
+
+@code{qemu-nbd -t --image-opts driver=raw,offset=1M,size=100M,file.driver=qcow2,file.backing.driver=file,file.backing.filename=file.qcow2}

I know you just moved it from above, but isn’t this wrong? Shouldn’t it be s/backing/file/g?

Indeed; file.file.driver=file,file.file.filename=file.qcow2 is required for it to work, rather than fail with
qemu-nbd: Failed to blk_new_open 'driver=raw,offset=1m,size=100m,file.driver=qcow2,file.backing.driver=file,file.backing.filename=file4': A block device must be specified for "file"

I'll repost with the bug-fix as a separate commit (and it's a shame that we've gone nearly a year with no one noticing the typo in the original).

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#4 lore raw
Quoted 26 lines · Eric Blake
Quoted 16 lines · Max Reitz
Quoted 14 lines · Eric Blake

The option was deprecated in 4.0.0 (commit 0ae2d546); it's now been long enough with no complaints to follow through with that process.

---

-@code{qemu-nbd -t -P 1 -f qcow2 file.qcow2}

qemu-deprecated.texi +0 -4
-
-can be rewritten as:
-
-@code{qemu-nbd -t --image-opts

driver=raw,offset=1M,size=100M,file.driver=qcow2,file.backing.driver=file,file.backing.filename=file.qcow2}

-

Quoted 8 lines
Quoted 5 lines
qemu-deprecated.texi +3 -0
+can be rewritten as:
+
+@code{qemu-nbd -t --image-opts

driver=raw,offset=1M,size=100M,file.driver=qcow2,file.backing.driver=file,file.backing.filename=file.qcow2}

I know you just moved it from above, but isn’t this wrong?  Shouldn’t it be s/backing/file/g?

Quoted 8 lines

Indeed; file.file.driver=file,file.file.filename=file.qcow2 is required
for it to work, rather than fail with
qemu-nbd: Failed to blk_new_open 'driver=raw,offset=1m,size=100m,file.driver=qcow2,file.backing.driver=file,file.backing.filename=file4':
A block device must be specified for "file"

I'll repost with the bug-fix as a separate commit (and it's a shame that we've gone nearly a year with no one noticing the typo in the original).

It was actually meant as a service to our users! So they can’t just blindly copy-paste the example but have to think it through. And the fact that noone has complained shows that our users indeed didn’t let themselves be caught off-guard! /s O:-)

Thanks!

Max