Skip to content

Improve qemu-img dd

Eric Blake qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2qemu-img: Fix dd with skip= and count=qemu-img.c tests/qemu-iotests/160 tests/qemu-iotests/160.out+70 -263 replies
2/2qemu-img: Add dd seek= optionqemu-img.c tests/qemu-iotests/160 tests/qemu-iotests/160.out+336 -2110 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [Qemu-devel] [PATCH 0/2] Improve qemu-img dd

I was trying to test NBD fleecing by copying subsets of one file to another, and had the idea to use:

$ export NBD drive to be fleeced on port 10809
$ qemu-img create -f qcow2 copy $size
$ qemu-nbd -f qcow2 -p 10810 copy
$ qemu-img dd -f raw -O raw if=nbd://localhost:10809 of=nbd://localhost:10810 \
    skip=$offset seek=$offset count=$((len/cluster)) bs=$cluster

except that seek= wasn't implemented. And in implementing that, I learned that skip= is broken when combined with count=.

[In the meantime, I had to use:

$ export NBD drive to be fleeced on port 10809
$ modprobe nbd
$ qemu-nbd -c /dev/nbd0 -f raw nbd://localhost:10809
$ qemu-nbd -c /dev/nbd1 -f qcow2 copy
$ dd if=/dev/nbd0 of/dev/nbd1 \
    skip=$offset seek=$offset count=$((len/cluster)) bs=$cluster

to get the behavior I needed (basically, create an empty qcow2 destination file, then plug in the guest-visible data based on the subsets of the disk of my choosing, by reading the block status/dirty bitmap over NBD). But bouncing through three NBD client/server pairs just so I can use plain 'dd' instead of just two pairs with 'qemu-img dd' feels dirty.
]

Eric Blake (2):
qemu-img: Fix dd with skip= and count=
qemu-img: Add dd seek= option

 qemu-img.c                 |  76 ++++++----
 tests/qemu-iotests/160     |  15 +-
 tests/qemu-iotests/160.out | 344 ++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 397 insertions(+), 38 deletions(-)
Signature · 1 line
2.14.4