Skip to contentSkip to conversation

qemu-img: add skip option to dd

PATCH In review Reda Sallahi 2 participants 2 messages Aug 10, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 qemu-img: add skip option to dd

This adds the skip option which allows qemu-img dd to skip a number of blocks before copying the input.

A test case was added to test the skip option.

---
Depends on:
[PATCH v9] qemu-img: add the 'dd' subcommand

Changes from v4:
* Rebase.
Changes from v3:
* Change write command to the test image in the test case. Changes from v2:
* Delete a tab that sneaked in (test case 160). Changes from v1:
* Change test case output.

 qemu-img-cmds.hx           |  4 +--
 qemu-img.c                 | 50 ++++++++++++++++++++++++++++----
 qemu-img.texi              |  4 ++-
 tests/qemu-iotests/160     | 72 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/160.out | 51 ++++++++++++++++++++++++++++++++
 tests/qemu-iotests/group   |  1 +
 6 files changed, 174 insertions(+), 8 deletions(-)
 create mode 100755 tests/qemu-iotests/160
 create mode 100644 tests/qemu-iotests/160.out
qemu-img-cmds.hx +2 -2
index 03bdd7a..f054599 100644
@@ -46,9 +46,9 @@ STEXI
 ETEXI
 
 DEF("dd", img_dd,
-    "dd [--image-opts] [-f fmt] [-O output_fmt] [bs=block_size] [count=blocks] if=input of=output")
+    "dd [--image-opts] [-f fmt] [-O output_fmt] [bs=block_size] [count=blocks] [skip=blocks] if=input of=output")
 STEXI
-@item dd [--image-opts] [-f @var{fmt}] [-O @var{output_fmt}] [bs=@var{block_size}] [count=@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}] if=@var{input} of=@var{output}
 ETEXI
 
 DEF("info", img_info,
qemu-img.c +45 -5

104 lines not on this page · raw message

qemu-img.texi +3 -1
index 880293a..174aae3 100644
@@ -151,6 +151,8 @@ sets the number of input blocks to copy
 sets the input file
 @item of=@var{output}
 sets the output file
+@item skip=@var{blocks}
+sets the number of input blocks to skip
 @end table
 
 Command description:
@@ -324,7 +326,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}] 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}] 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/160 new file +72 -0

72 lines not on this page · raw message

tests/qemu-iotests/160.out new file +51 -0

51 lines not on this page · raw message

tests/qemu-iotests/group +1 -0
index ec712bc..a042f48 100644
@@ -159,3 +159,4 @@
 157 auto
 158 rw auto quick
 159 rw auto quick
+160 rw auto quick
Signature · 1 line
2.9.2
#1 lore raw
Quoted 28 lines · Reda Sallahi

This adds the skip option which allows qemu-img dd to skip a number of blocks before copying the input.

A test case was added to test the skip option.

---
Depends on:
[PATCH v9] qemu-img: add the 'dd' subcommand

Changes from v4:
* Rebase.
Changes from v3:
* Change write command to the test image in the test case. Changes from v2:
* Delete a tab that sneaked in (test case 160). Changes from v1:
* Change test case output.

 qemu-img-cmds.hx           |  4 +--
 qemu-img.c                 | 50 ++++++++++++++++++++++++++++----
 qemu-img.texi              |  4 ++-
 tests/qemu-iotests/160     | 72 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/160.out | 51 ++++++++++++++++++++++++++++++++
 tests/qemu-iotests/group   |  1 +
 6 files changed, 174 insertions(+), 8 deletions(-)
 create mode 100755 tests/qemu-iotests/160
 create mode 100644 tests/qemu-iotests/160.out

[...]

Quoted 4 lines
qemu-img.c +0 -0
index 034baf7..3adec86 100644

[...]

Quoted 1 line
qemu-img.c +0 -0
@@ -4049,9 +4078,20 @@ static int img_dd(int argc, char **argv)

[...]

qemu-img.c static int img_dd(int argc, char **argv) · line 4094

Quoted 2 lines
qemu-img.c +1 -1
-    for (in_pos = 0, out_pos = 0; in_pos < size; block_count++) {
+    for (out_pos = 0; in_pos < size; block_count++) {

*whistle* /me hopes nobody will notice that block_count is absolutely unused apart from this place...

Anyway, thanks, I've applied this patch to my block-next branch:

https://github.com/XanClic/qemu/commits/block-next

Max