qemu-img: check bs_n when use old style option
PATCH 1/1 qemu-img: check bs_n when use old style option
From: Lidong Chen <[email protected]>
When use old style option like -o backing_file, img_convert continue run when bs_n > 1, this patch fix this bug.
--- qemu-img.c | 7 +++++++ 1 file changed, 7 insertions(+)
qemu-img.c +7 -0
@@ -2225,6 +2225,13 @@ static int img_convert(int argc, char **argv) out_baseimg = out_baseimg_param; } +if (bs_n >1 && out_baseimg) { +error_report ("-B makes no sense when concatenating multiple input " +"images" ); + ret =-1 ; + goto out; + } +/* Check if compression is supported */ if (compress) { bool encryption =
Signature · 1 line
1.8.3.1
Quoted 32 lines · On Thu, 04/20 12:04, [email protected] wrote:
From: Lidong Chen <[email protected]>
When use old style option like -o
backing_file,img_convertcontinue run whenbs_n> 1, this patch fix this bug.Signed-off-by Lidong Chen <[email protected]>--- qemu-img.c | 7 +++++++ 1 file changed, 7 insertions(+)qemu-img.c +7
-0@@ -2225,6 +2225,13 @@ static int img_convert(int argc, char **argv) out_baseimg = out_baseimg_param; } +if (bs_n >1 && out_baseimg) { +error_report ("-B makes no sense when concatenating multiple input " +"images" ); + ret =-1 ; + goto out; + } +/* Check if compression is supported */ if (compress) { bool encryption =Signature · 1 line
1.8.3.1
Is this essentially the same as the check a few lines above:
...
if (bs_n < 1) {
error_exit("Must specify image file name");
}
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) {
error_report("Invalid source cache option: %s", src_cache);
goto out;
}
...How about moving that down?
Fam
Quoted 57 lines · Fam Zheng
Quoted 29 lines · On Thu, 04/20 12:04, [email protected] wrote:
From: Lidong Chen <[email protected]>
When use old style option like -o
backing_file,img_convertcontinue run whenbs_n> 1, this patch fix this bug.Signed-off-by Lidong Chen <[email protected]>--- qemu-img.c | 7 +++++++ 1 file changed, 7 insertions(+)qemu-img.c +7
-1@@ -2225,6 +2225,13 @@ static int img_convert(int argc, char **argv) out_baseimg = out_baseimg_param; } +if (bs_n >1 && out_baseimg) { +error_report ("-B makes no sense when concatenating multiple input " +"images" ); + ret =-1 ; + goto out; + } +/* Check if compression is supported */ if (compress) { bool encryption = --Quoted 3 lines
1.8.3.1
Is this essentially the same as the check a few lines above:
... if (bs_n < 1) { error_exit("Must specify image file name"); } 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) { error_report("Invalid source cache option: %s", src_cache); goto out; } ...
Quoted 1 line
How about moving that down?
moving that down is ok.
but will exit later if use -B option.
which way do you think better?
Quoted 2 lines
Fam
Quoted 58 lines · On Thu, 04/20 15:59, 858585 jemmy wrote:
Quoted 57 lines · Fam Zheng
Quoted 29 lines · On Thu, 04/20 12:04, [email protected] wrote:
From: Lidong Chen <[email protected]>
When use old style option like -o
backing_file,img_convertcontinue run whenbs_n> 1, this patch fix this bug.Signed-off-by Lidong Chen <[email protected]>--- qemu-img.c | 7 +++++++ 1 file changed, 7 insertions(+)qemu-img.c +7
-1@@ -2225,6 +2225,13 @@ static int img_convert(int argc, char **argv) out_baseimg = out_baseimg_param; } +if (bs_n >1 && out_baseimg) { +error_report ("-B makes no sense when concatenating multiple input " +"images" ); + ret =-1 ; + goto out; + } +/* Check if compression is supported */ if (compress) { bool encryption = --Quoted 3 lines
1.8.3.1
Is this essentially the same as the check a few lines above:
... if (bs_n < 1) { error_exit("Must specify image file name"); } 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) { error_report("Invalid source cache option: %s", src_cache); goto out; } ...
Quoted 4 lines
Quoted 1 line
How about moving that down?
moving that down is ok.
but will exit later if use -B option.
which way do you think better?
Exiting later is not a problem, I assume? And it's better to avoid duplicating code if possible.
BTW if you do that way, it's better to "s/-B/Specifying backing image/" in the error message (to be compatible with -o backing_file syntax).
Fam
Quoted 64 lines · Fam Zheng
Quoted 58 lines · On Thu, 04/20 15:59, 858585 jemmy wrote:
Quoted 57 lines · Fam Zheng
Quoted 29 lines · On Thu, 04/20 12:04, [email protected] wrote:
From: Lidong Chen <[email protected]>
When use old style option like -o
backing_file,img_convertcontinue run whenbs_n> 1, this patch fix this bug.Signed-off-by Lidong Chen <[email protected]>--- qemu-img.c | 7 +++++++ 1 file changed, 7 insertions(+)qemu-img.c +7
-1@@ -2225,6 +2225,13 @@ static int img_convert(int argc, char **argv) out_baseimg = out_baseimg_param; } +if (bs_n >1 && out_baseimg) { +error_report ("-B makes no sense when concatenating multiple input " +"images" ); + ret =-1 ; + goto out; + } +/* Check if compression is supported */ if (compress) { bool encryption = --Quoted 3 lines
1.8.3.1
Is this essentially the same as the check a few lines above:
... if (bs_n < 1) { error_exit("Must specify image file name"); } 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) { error_report("Invalid source cache option: %s", src_cache); goto out; } ...Quoted 4 lines
Quoted 1 line
How about moving that down?
moving that down is ok.
but will exit later if use -B option.
which way do you think better?
Quoted 5 lines
Exiting later is not a problem, I assume? And it's better to avoid duplicating code if possible.
BTW if you do that way, it's better to "s/-B/Specifying backing image/" in the error message (to be compatible with -o
backing_filesyntax).
Thanks. i will submit this patch again.
Quoted 2 lines
Fam