On 1/23/19 3:55 PM, Richard W.M. Jones wrote: > On Wed, Jan 23, 2019 at 03:19:53PM -0600, Eric Blake wrote: >> The existing qemu-nbd --partition code claims to handle logical >> partitions up to 8, since its introduction in 2008 (commit 7a5ca86). >> However, the implementation is bogus (actual MBR logical partitions >> form a sort of linked list, with one partition per extended table >> entry, rather than four logical partitions in a single extended >> table), making the code unlikely to work for anything beyond -P5 on >> actual guest images. What's more, the code does not support GPT >> partitions, which are becoming more popular, and maintaining device >> subsetting in both NBD and the raw device is unnecessary maintenance >> burden. And nbdkit has just added code to properly handle an >> arbitrary number of MBR partitions, along with its existing code >> for handling GPT partitions. >> >> Note that obtaining the offsets of a partition can be learned by >> using 'qemu-nbd -c /dev/nbd0 file.qcow2 && sfdisk --dump /dev/nbd0', >> but by the time you've done that, you might as well just mount >> /dev/nbd0p1 that the kernel creates for you. >> >> Start the clock on the deprecation cycle, with an example of how >> to write device subsetting without using -P. >> >> +For example, if partition 1 is 100MiB starting at 1MiB, the old command >> + >> +@example{qemu-nbd -P 1 -f qcow2 file.qcow2} >> + >> +can be rewritten as: >> + >> +@example{qemu-nbd --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. > > You might want to add the actual command here. Good idea - as long as we are deprecating something, telling the user how to get the same functionality (in this case, user-space partition detection, without involving /dev/nbd) is worth the extra effort. > Unfortunately nbdkit > cannot read qcow2 files meaning (as you note already) that you have to > forward the connection through the nbdkit-nbd-plugin to qemu-nbd. > This worked for me: > > qemu-nbd -t -k /tmp/sock -f qcow2 file.qcow2 & > nbdkit -f --filter=partition nbd socket=/tmp/sock partition=1 & Is the -f necessary? Otherwise, yes, this looks reasonable. I'll add it for v2. > If you drop the requirement to demonstrate this with qcow2 then the > command would be just this: > > nbdkit --filter=partition file disk.raw partition=1 > -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list