qemu-img: add seek option to dd
PATCH 1/1 qemu-img: add seek option to dd
This patch adds the seek option which allows qemu-img dd to skip a number of blocks on the output before copying the input.
A test case was added to test the seek option.
---
Depends on:
[PATCH v5] qemu-img: add skip option to dd
qemu-img-cmds.hx | 4 +- qemu-img.c | 116 ++++++++++++++++++++++++++++++++++++++------- qemu-img.texi | 4 +- tests/qemu-iotests/161 | 72 ++++++++++++++++++++++++++++ tests/qemu-iotests/161.out | 51 ++++++++++++++++++++ tests/qemu-iotests/group | 1 + 6 files changed, 228 insertions(+), 20 deletions(-) create mode 100755 tests/qemu-iotests/161 create mode 100644 tests/qemu-iotests/161.out
qemu-img-cmds.hx +2 -2
@@ -46,9 +46,9 @@ STEXI ETEXI DEF("dd", img_dd, - "dd [--image-opts] [-f fmt] [-O output_fmt] [bs=block_size] [count=blocks] [skip=blocks] if=input of=output") + "dd [--image-opts] [-f fmt] [-O output_fmt] [bs=block_size] [count=blocks] [skip=blocks] [seek=blocks] if=input of=output") STEXI -@item dd [--image-opts] [-f @var{fmt}] [-O @var{output_fmt}] [bs=@var{block_size}] [count=@var{blocks}] [skip=@var{blocks}] if=@var{input} of=@var{output} +@item dd [--image-opts] [-f @var{fmt}] [-O @var{output_fmt}] [bs=@var{block_size}] [count=@var{blocks}] [skip=@var{blocks}] [seek=@var{blocks}] if=@var{input} of=@var{output} ETEXI DEF("info", img_info,
qemu-img.c +99 -17
173 lines not on this page · raw message
qemu-img.texi +3 -1
@@ -153,6 +153,8 @@ sets the input file sets the output file @item skip=@var{blocks} sets the number of input blocks to skip +@item seek=@var{blocks} +sets the number of output blocks to skip @end table Command description:
@@ -326,7 +328,7 @@ skipped. This is useful for formats such as @code{rbd} if the target volume has already been created with site specific options that cannot be supplied through qemu-img. -@item dd [-f @var{fmt}] [-O @var{output_fmt}] [bs=@var{block_size}] [count=@var{blocks}] [skip=@var{blocks}] if=@var{input} of=@var{output} +@item dd [-f @var{fmt}] [-O @var{output_fmt}] [bs=@var{block_size}] [count=@var{blocks}] [skip=@var{blocks}] [seek=@var{blocks}] if=@var{input} of=@var{output} Dd copies from @var{input} file to @var{output} file converting it from @var{fmt} format to @var{output_fmt} format.
tests/qemu-iotests/161 new file +72 -0
72 lines not on this page · raw message
tests/qemu-iotests/161.out new file +51 -0
51 lines not on this page · raw message
tests/qemu-iotests/group +1 -0
@@ -160,3 +160,4 @@ 158 rw auto quick 159 rw auto quick 160 rw auto quick +161 rw auto quick
Signature · 1 line
2.9.2
Quoted 10 lines · Reda Sallahi
This patch adds the seek option which allows qemu-img dd to skip a number of blocks on the output before copying the input.
A test case was added to test the seek option.
Signed-off-by Reda Sallahi <[email protected]>---
Depends on:
[PATCH v5] qemu-img: add skip option to dd
Quoted 9 lines
qemu-img-cmds.hx | 4 +- qemu-img.c | 116 ++++++++++++++++++++++++++++++++++++++------- qemu-img.texi | 4 +- tests/qemu-iotests/161 | 72 ++++++++++++++++++++++++++++ tests/qemu-iotests/161.out | 51 ++++++++++++++++++++ tests/qemu-iotests/group | 1 + 6 files changed, 228 insertions(+), 20 deletions(-) create mode 100755 tests/qemu-iotests/161 create mode 100644 tests/qemu-iotests/161.out
On IRC, Kevin has raised concern that qemu-img dd should never truncate the output image, or at least not until told to do so.
While I do not share his opinion, I do share his concern that people may fall into this trap. Therefore, I propose doing two things:
First, we should merge a patch which implements conv=notrunc. Without qemu-img dd actually truncating anything yet, that will be rather trivial. However, I think that until we have come to a conclusion on how to handle the case where conv=notrunc has not been passed, we should actually make conv=notrunc mandatory. That is, the patch implementing conv=notrunc should also make qemu-img dd error out if it has not been specified.
I admit this is a rather stupid idea but I think it will do the trick for now.
Second, this patch should be separated into two parts: The first of which make qemu-img dd no longer create the output image if it exists already, and the second of which then implements the seek option. Those are two different things so I think they should be done in two different patches.
Max