qemu-img: add the 'dd' subcommand
PATCH v3 1/1 qemu-img: add the 'dd' subcommand
This patch adds a basic dd subcommand analogous to dd(1) to qemu-img.
For the start, this implements the bs, if, of and count options and requires both if and of to be specified (no stdin/stdout if not specified) and doesn't support tty, pipes, etc.
The image format must be specified with -O for the output if the raw format is not the intended one.
Two tests are added to test qemu-img dd.
---
Changes from v2:
* Added copyright headers to new files.
Changes from v1:
* Removal of dead code.
* Fix a memory leak.
* Complete the cleanup function in the test cases.
qemu-img-cmds.hx | 6 + qemu-img.c | 364 ++++++++++++++++++++++++++++++++++++++- tests/qemu-iotests/158 | 68 ++++++++ tests/qemu-iotests/158.out | 15 ++ tests/qemu-iotests/159 | 70 ++++++++ tests/qemu-iotests/159.out | 87 ++++++++++ tests/qemu-iotests/common.filter | 9 + tests/qemu-iotests/group | 2 + 8 files changed, 620 insertions(+), 1 deletion(-) create mode 100755 tests/qemu-iotests/158 create mode 100644 tests/qemu-iotests/158.out create mode 100755 tests/qemu-iotests/159 create mode 100644 tests/qemu-iotests/159.out
qemu-img-cmds.hx +6 -0
@@ -45,6 +45,12 @@ STEXI @item convert [--object @var{objectdef}] [--image-opts] [-c] [-p] [-q] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_id_or_name}] [-l @var{snapshot_param}] [-S @var{sparse_size}] @var{filename} [@var{filename2} [...]] @var{output_filename} ETEXI +DEF("dd", img_dd, + "dd [--image-opts] [-f fmt] [-O output_fmt] [bs=block_size] [count=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} +ETEXI + DEF("info", img_info, "info [--object objectdef] [--image-opts] [-f fmt] [--output=ofmt] [--backing-chain] filename") STEXI
qemu-img.c +363 -1
376 lines not on this page · raw message
tests/qemu-iotests/158 new file +68 -0
68 lines not on this page · raw message
tests/qemu-iotests/158.out new file +15 -0
@@ -0,0 +1,15 @@ +QA output created by 158 + +== Creating image == +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 +No errors were found on the image. +wrote 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== Converting the image with dd == +No errors were found on the image. + +== Compare the images with qemu-img compare == +Images are identical. + +*** done
tests/qemu-iotests/159 new file +70 -0
70 lines not on this page · raw message
tests/qemu-iotests/159.out new file +87 -0
87 lines not on this page · raw message
tests/qemu-iotests/common.filter +9 -0
@@ -44,6 +44,15 @@ _filter_imgfmt() sed -e "s#$IMGFMT#IMGFMT#g" } +# replace error message when the format is not supported and delete +# the output lines after the first one +_filter_qemu_img_check() +{ + sed -e '/allocated.*fragmented.*compressed clusters/d' \ + -e 's/qemu-img: This image format does not support checks/No errors were found on the image./' \ + -e '/Image end offset: [0-9]\+/d' +} + # Removes \r from messages _filter_win32() {
tests/qemu-iotests/group +2 -0
@@ -157,3 +157,5 @@ 155 rw auto 156 rw auto quick 157 auto +158 rw auto quick +159 rw auto quick
Signature · 1 line
2.9.0
Quoted 21 lines · Reda Sallahi
This patch adds a basic dd subcommand analogous to dd(1) to qemu-img.
For the start, this implements the bs, if, of and count options and requires both if and of to be specified (no stdin/stdout if not specified) and doesn't support tty, pipes, etc.
The image format must be specified with -O for the output if the raw format is not the intended one.
Two tests are added to test qemu-img dd.
Signed-off-by Reda Sallahi <[email protected]>---
Changes from v2:
* Added copyright headers to new files.Changes from v1:
* Removal of dead code.
* Fix a memory leak.
* Complete the cleanup function in the test cases.
Quoted 13 lines
qemu-img-cmds.hx | 6 + qemu-img.c | 364 ++++++++++++++++++++++++++++++++++++++- tests/qemu-iotests/158 | 68 ++++++++ tests/qemu-iotests/158.out | 15 ++ tests/qemu-iotests/159 | 70 ++++++++ tests/qemu-iotests/159.out | 87 ++++++++++ tests/qemu-iotests/common.filter | 9 + tests/qemu-iotests/group | 2 + 8 files changed, 620 insertions(+), 1 deletion(-) create mode 100755 tests/qemu-iotests/158 create mode 100644 tests/qemu-iotests/158.out create mode 100755 tests/qemu-iotests/159 create mode 100644 tests/qemu-iotests/159.out
qemu-img.c out: · line 3816
Quoted 3 lines · Reda Sallahi
qemu-img.c +3
-0+struct DdIo { +size_t bsz;/* Block size */ +off_t offset;
Oops, I did notice this.
No POSIX APIs with off_t are used. Please use the QEMU block layer's int64_t type instead.
Stefan