add qemu-img convert -n option (skip target volume creation)
PATCH v7 1/1 add qemu-img convert -n option (skip target volume creation)
From: Alexandre Derumier <[email protected]>
Add a -n option to skip volume creation on qemu-img convert. This is useful for targets such as rbd / ceph, where the target volume may already exist; we cannot always rely on qemu-img convert to create the image, as dependent on the output format, there may be parameters which are not possible to specify through the qemu-img convert command line.
---
Changes since v6:
* Check for outut file too short using bdrv_getlength (Stefan H)
* Remove spurious comment re compression from test (Stefan H)
* Remove unused variables from test (Stefan H)
Changes since v5:
* Change order of case statement for -n to be after -q
* Add my own copyright string (per Eric Blake)
qemu-img-cmds.hx | 4 +- qemu-img.c | 53 +++++++++++++++++------- qemu-img.texi | 15 ++++++- tests/qemu-iotests/060 | 97 ++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/060.out | 10 +++++ tests/qemu-iotests/group | 1 + 6 files changed, 162 insertions(+), 18 deletions(-)
qemu-img-cmds.hx +2 -2
@@ -34,9 +34,9 @@ STEXI ETEXI DEF("convert", img_convert, - "convert [-c] [-p] [-q] [-f fmt] [-t cache] [-O output_fmt] [-o options] [-s snapshot_name] [-S sparse_size] filename [filename2 [...]] output_filename") + "convert [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-O output_fmt] [-o options] [-s snapshot_name] [-S sparse_size] filename [filename2 [...]] output_filename") STEXI -@item convert [-c] [-p] [-q] [-f @var{fmt}] [-t @var{cache}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_name}] [-S @var{sparse_size}] @var{filename} [@var{filename2} [...]] @var{output_filename} +@item convert [-c] [-p] [-q] [-n] [-f @var{fmt}] [-t @var{cache}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_name}] [-S @var{sparse_size}] @var{filename} [@var{filename2} [...]] @var{output_filename} ETEXI DEF("info", img_info,
qemu-img.c +38 -15
91 lines not on this page · raw message
qemu-img.texi +14 -1
@@ -96,6 +96,14 @@ Second image format Strict mode - fail on on different image size or sector allocation @end table +Parameters to convert subcommand: + +@table @option + +@item -n +Skip the creation of the target volume +@end table + Command description: @table @option
@@ -171,7 +179,7 @@ Error on reading data @end table -@item convert [-c] [-p] [-f @var{fmt}] [-t @var{cache}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_name}] [-S @var{sparse_size}] @var{filename} [@var{filename2} [...]] @var{output_filename} +@item convert [-c] [-p] [-n] [-f @var{fmt}] [-t @var{cache}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_name}] [-S @var{sparse_size}] @var{filename} [@var{filename2} [...]] @var{output_filename} Convert the disk image @var{filename} or a snapshot @var{snapshot_name} to disk image @var{output_filename} using format @var{output_fmt}. It can be optionally compressed (@code{-c}
@@ -190,6 +198,11 @@ created as a copy on write image of the specified base image; the @var{backing_file} should have the same content as the input's base image, however the path, image format, etc may differ. +If the @code{-n} option is specified, the target volume creation will be +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 info [-f @var{fmt}] [--output=@var{ofmt}] [--backing-chain] @var{filename} Give information about the disk image @var{filename}. Use it in
tests/qemu-iotests/060 new file +97 -0
97 lines not on this page · raw message
tests/qemu-iotests/060.out new file +10 -0
@@ -0,0 +1,10 @@ +QA output created by 060 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4194304 +== Testing conversion with -n fails with no target file == +== Testing conversion with -n succeeds with a target file == +== Testing conversion to raw is the same after conversion with -n == +== Testing conversion back to original format == +No errors were found on the image. +== Testing conversion to a smaller file fails == +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2097152 +*** done
tests/qemu-iotests/group +1 -0
@@ -64,3 +64,4 @@ 055 rw auto 056 rw auto backing 059 rw auto +060 rw auto
Signature · 1 line
1.7.9.5
Stefan Hajnoczi
AppliedQuoted 23 lines · Alex Bligh
From: Alexandre Derumier <[email protected]>
Add a -n option to skip volume creation on qemu-img convert. This is useful for targets such as rbd / ceph, where the target volume may already exist; we cannot always rely on qemu-img convert to create the image, as dependent on the output format, there may be parameters which are not possible to specify through the qemu-img convert command line.
Reviewed-by Eric Blake <[email protected]>Signed-off-by Alexandre Derumier <[email protected]>Signed-off-by Alex Bligh <[email protected]>---
Changes since v6:
* Check for outut file too short usingbdrv_getlength(Stefan H)
* Remove spurious comment re compression from test (Stefan H)
* Remove unused variables from test (Stefan H)Changes since v5:
* Change order of case statement for -n to be after -q
* Add my own copyright string (per Eric Blake)
Quoted 7 lines
qemu-img-cmds.hx | 4 +- qemu-img.c | 53 +++++++++++++++++------- qemu-img.texi | 15 ++++++- tests/qemu-iotests/060 | 97 ++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/060.out | 10 +++++ tests/qemu-iotests/group | 1 + 6 files changed, 162 insertions(+), 18 deletions(-)
Due to the collision with Max's 060 I changed your test case number to 063.
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan