qemu-img/convert: Some small fixes
cover qemu-img/convert: Some small fixes
This series fixes some small issues I found in qemu-img's convert subcommand while reviewing Dan's convert/dd series.
Nothing serious at all, so all for 2.10.
Max Reitz (3):
qemu-img/convert: Always set ret < 0 on error qemu-img/convert: Use @opts for one thing only qemu-img/convert: Move bs_n > 1 && -B check down
qemu-img.c | 26 +++++++++++++++----------- tests/qemu-iotests/122.out | 4 ++-- 2 files changed, 17 insertions(+), 13 deletions(-)
Signature · 1 line
2.12.2
PATCH 1/3 qemu-img/convert: Always set ret < 0 on error
Otherwise the qemu-img process will exit with EXIT_SUCCESS instead of EXIT_FAILURE.
--- qemu-img.c | 2 ++ 1 file changed, 2 insertions(+)
qemu-img.c +2 -0
@@ -2069,6 +2069,7 @@ static int img_convert(int argc, char **argv) opts =qemu_opts_parse_noisily (&qemu_object_opts, optarg, true);if (!opts) { + ret =-1 ; goto fail_getopt; }break ;
@@ -2081,6 +2082,7 @@ static int img_convert(int argc, char **argv)if (qemu_opts_foreach (&qemu_object_opts, user_creatable_add_opts_foreach,NULL ,NULL )) { + ret =-1 ; goto fail_getopt; }
Signature · 1 line
2.12.2
Re: [Qemu-devel] [PATCH for-2.10 1/3] qemu-img/convert: Always set ret < 0 on error
Quoted 8 lines · Max Reitz
Otherwise the qemu-img process will exit with
EXIT_SUCCESSinstead ofEXIT_FAILURE.Cc qemu-stable <[email protected]>Signed-off-by Max Reitz <[email protected]>--- qemu-img.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 22 lines
qemu-img.c +2
-0@@ -2069,6 +2069,7 @@ static int img_convert(int argc, char **argv) opts =qemu_opts_parse_noisily (&qemu_object_opts, optarg, true);if (!opts) { + ret =-1 ; goto fail_getopt; }break ;@@ -2081,6 +2082,7 @@ static int img_convert(int argc, char **argv)if (qemu_opts_foreach (&qemu_object_opts, user_creatable_add_opts_foreach,NULL ,NULL )) { + ret =-1 ; goto fail_getopt; }
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH for-2.10 1/3] qemu-img/convert: Always set ret < 0 on error
In reply to Max ReitzQuoted 5 lines · Max Reitz
Otherwise the qemu-img process will exit with
EXIT_SUCCESSinstead ofEXIT_FAILURE.Cc qemu-stable <[email protected]>Signed-off-by Max Reitz <[email protected]>
Quoted 25 lines
--- qemu-img.c | 2 ++ 1 file changed, 2 insertions(+)qemu-img.c +2
-0@@ -2069,6 +2069,7 @@ static int img_convert(int argc, char **argv) opts =qemu_opts_parse_noisily (&qemu_object_opts, optarg, true);if (!opts) { + ret =-1 ; goto fail_getopt; }break ;@@ -2081,6 +2082,7 @@ static int img_convert(int argc, char **argv)if (qemu_opts_foreach (&qemu_object_opts, user_creatable_add_opts_foreach,NULL ,NULL )) { + ret =-1 ; goto fail_getopt; }
PATCH 2/3 qemu-img/convert: Use @opts for one thing only
In reply to Max ReitzAfter storing the creation options for the new image into @opts, we fetch some things for our own information, like the backing file name, or whether to use encryption or preallocation.
With the -n parameter, there will not be any creation options; this is not too bad because this just means that querying a NULL @opts will always return the default value.
However, we also use @opts for the --object options. Therefore, @opts is not necessarily NULL if -n was specified; instead, it may contain those options. In practice, this probably does not cause any problems because there most likely is no object that supports any of the parameters we query here, but this is neither something we should rely on nor does this variable reuse make the code very nice to read.
Therefore, just use an own variable for the --object options.
--- qemu-img.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
qemu-img.c +6 -4
@@ -2065,14 +2065,16 @@ static int img_convert(int argc, char **argv)case 'W' : wr_in_order = false;break ; -case OPTION_OBJECT : - opts =qemu_opts_parse_noisily (&qemu_object_opts, - optarg, true); -if (!opts) { +case OPTION_OBJECT : { +QemuOpts *object_opts; + object_opts =qemu_opts_parse_noisily (&qemu_object_opts, + optarg, true); +if (!object_opts) { ret =-1 ; goto fail_getopt; }break ; + }case OPTION_IMAGE_OPTS : image_opts = true;break ;
Signature · 1 line
2.12.2
Re: [Qemu-devel] [PATCH for-2.10 2/3] qemu-img/convert: Use @opts for one thing only
Quoted 15 lines · Max Reitz
After storing the creation options for the new image into @opts, we fetch some things for our own information, like the backing file name, or whether to use encryption or preallocation.
With the -n parameter, there will not be any creation options; this is not too bad because this just means that querying a NULL @opts will always return the default value.
However, we also use @opts for the --object options. Therefore, @opts is not necessarily NULL if -n was specified; instead, it may contain those options. In practice, this probably does not cause any problems because there most likely is no object that supports any of the parameters we query here, but this is neither something we should rely on nor does this variable reuse make the code very nice to read.
Quoted 8 lines
Therefore, just use an own variable for the --object options.
Cc qemu-stable <[email protected]>Signed-off-by Max Reitz <[email protected]>--- qemu-img.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 3/3 qemu-img/convert: Move bs_n > 1 && -B check down
In reply to Max ReitzIt does not make much sense to use a backing image for the target when you concatenate multiple images (because then there is no correspondence between the source images' backing files and the target's); but it was still possible to give one by using -o backing_file=X instead of -B X.
Fix this by moving the check.
(Also, change the error message because -B is not the only way to
specify the backing file, evidently.)
--- qemu-img.c | 14 +++++++------- tests/qemu-iotests/122.out | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-)
qemu-img.c +7 -7
@@ -2113,13 +2113,6 @@ static int img_convert(int argc, char **argv) } -if (bs_n >1 && out_baseimg) { -error_report ("-B makes no sense when concatenating multiple input " -"images" ); - ret =-1 ; - goto out; - } - src_flags =0 ; ret =bdrv_parse_cache_mode (src_cache, &src_flags, &src_writethrough);if (ret <0 ) {
@@ -2229,6 +2222,13 @@ static int img_convert(int argc, char **argv) out_baseimg = out_baseimg_param; } +if (bs_n >1 && out_baseimg) { +error_report ("Having a backing file for the target makes no sense when " +"concatenating multiple input images" ); + ret =-1 ; + goto out; + } +/* Check if compression is supported */ if (compress) { bool encryption =
tests/qemu-iotests/122.out +2 -2
@@ -61,8 +61,8 @@ read 65536/65536 bytes at offset 4194304 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 8388608 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qemu-img: -B makes no sense when concatenating multiple input images -qemu-img: -B makes no sense when concatenating multiple input images +qemu-img: Having a backing file for the target makes no sense when concatenating multiple input images +qemu-img: Having a backing file for the target makes no sense when concatenating multiple input images === Compression with misaligned allocations and image sizes ===
Signature · 1 line
2.12.2
Re: [Qemu-devel] [PATCH for-2.10 3/3] qemu-img/convert: Move bs_n > 1 && -B check down
Quoted 9 lines · Max Reitz
It does not make much sense to use a backing image for the target when you concatenate multiple images (because then there is no correspondence between the source images' backing files and the target's); but it was still possible to give one by using -o backing_file=X instead of -B X.
Fix this by moving the check.
(Also, change the error message because -B is not the only way to
specify the backing file, evidently.)
For that matter, 'create -B' is intentionally? undocumented in the qemu-img --help and man page. (Personally, I don't know why we don't want it documented - is it because it it not a universal option because not all formats support backing files?)
Quoted 8 lines
Cc qemu-stable <[email protected]>Signed-off-by Max Reitz <[email protected]>--- qemu-img.c | 14 +++++++------- tests/qemu-iotests/122.out | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-)
Having a backing file for the destination may still make sense for some convoluted workflow, but you can get that with a followup qemu-img rebase.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH for-2.10 3/3] qemu-img/convert: Move bs_n > 1 && -B check down
Quoted 8 lines · Eric Blake
Quoted 7 lines · Max Reitz
It does not make much sense to use a backing image for the target when you concatenate multiple images (because then there is no correspondence between the source images' backing files and the target's); but it was still possible to give one by using -o backing_file=X instead of -B X.
Fix this by moving the check.
Quoted 7 lines
Quoted 2 lines
(Also, change the error message because -B is not the only way to
specify the backing file, evidently.)For that matter, 'create -B' is intentionally? undocumented in the qemu-img --help and man page. (Personally, I don't know why we don't want it documented - is it because it it not a universal option because not all formats support backing files?)
(I suppose you mean convert instead of create)
Well, the man page at least documents that you can use backing_file for the destination and what it will do. So documenting would probably be just "Oh, you can also use -B, by the way."
I won't promise to write a patch to fix that, but I do hope I will. :-)
Quoted 9 lines
Quoted 7 lines
Cc qemu-stable <[email protected]>Signed-off-by Max Reitz <[email protected]>--- qemu-img.c | 14 +++++++------- tests/qemu-iotests/122.out | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-)Reviewed-by Eric Blake <[email protected]>
Thanks, as always!
Max
Quoted 2 lines
Having a backing file for the destination may still make sense for some convoluted workflow, but you can get that with a followup qemu-img rebase.
Am 13.04.2017 um 22:33 hat Max Reitz geschrieben:
Quoted 4 lines
This series fixes some small issues I found in qemu-img's convert subcommand while reviewing Dan's convert/dd series.
Nothing serious at all, so all for 2.10.
This series conflicts with Peter Lieven's "qemu-img: simplify img_convert" in my block-next branch.
Patch 1 is unnecessary now (ret is still -EINVAL at this point), the other two probably just need rebasing.
Kevin
Quoted 11 lines · Kevin Wolf
Am 13.04.2017 um 22:33 hat Max Reitz geschrieben:
Quoted 4 lines
This series fixes some small issues I found in qemu-img's convert subcommand while reviewing Dan's convert/dd series.
Nothing serious at all, so all for 2.10.
This series conflicts with Peter Lieven's "qemu-img: simplify
img_convert" in my block-next branch.Patch 1 is unnecessary now (ret is still
-EINVALat this point), the other two probably just need rebasing.
Hm... What should I do about qemu-stable, though? I don't think that Peter's series will end up there, so qemu-stable should probably indeed take v1...
Max
Am 26.04.2017 um 14:48 hat Max Reitz geschrieben:
Quoted 10 lines · Kevin Wolf
Quoted 9 lines
Am 13.04.2017 um 22:33 hat Max Reitz geschrieben:
Quoted 4 lines
This series fixes some small issues I found in qemu-img's convert subcommand while reviewing Dan's convert/dd series.
Nothing serious at all, so all for 2.10.
This series conflicts with Peter Lieven's "qemu-img: simplify
img_convert" in my block-next branch.
Quoted 6 lines
Quoted 2 lines
Patch 1 is unnecessary now (ret is still
-EINVALat this point), the other two probably just need rebasing.Hm... What should I do about qemu-stable, though? I don't think that Peter's series will end up there, so qemu-stable should probably indeed take v1...
Yes, this is true. We probably need a patch specifically for qemu-stable then and a different one for master.
Kevin