All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu-img: check bs_n when use old style option
@ 2017-04-20  4:04 jemmy858585
  2017-04-20  7:51 ` Fam Zheng
  0 siblings, 1 reply; 5+ messages in thread
From: jemmy858585 @ 2017-04-20  4:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, mreitz, qemu-block, Lidong Chen

From: Lidong Chen <lidongchen@tencent.com>

When use old style option like -o backing_file, img_convert
continue run when bs_n > 1, this patch fix this bug.

Signed-off-by: Lidong Chen <lidongchen@tencent.com>
---
 qemu-img.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/qemu-img.c b/qemu-img.c
index b220cf7..c673aef 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -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 =
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-img: check bs_n when use old style option
  2017-04-20  4:04 [Qemu-devel] [PATCH] qemu-img: check bs_n when use old style option jemmy858585
@ 2017-04-20  7:51 ` Fam Zheng
  2017-04-20  7:59   ` 858585 jemmy
  0 siblings, 1 reply; 5+ messages in thread
From: Fam Zheng @ 2017-04-20  7:51 UTC (permalink / raw)
  To: jemmy858585; +Cc: qemu-devel, kwolf, Lidong Chen, qemu-block, mreitz

On Thu, 04/20 12:04, jemmy858585@gmail.com wrote:
> From: Lidong Chen <lidongchen@tencent.com>
> 
> When use old style option like -o backing_file, img_convert
> continue run when bs_n > 1, this patch fix this bug.
> 
> Signed-off-by: Lidong Chen <lidongchen@tencent.com>
> ---
>  qemu-img.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/qemu-img.c b/qemu-img.c
> index b220cf7..c673aef 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -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 =
> -- 
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-img: check bs_n when use old style option
  2017-04-20  7:51 ` Fam Zheng
@ 2017-04-20  7:59   ` 858585 jemmy
  2017-04-20  8:11     ` Fam Zheng
  0 siblings, 1 reply; 5+ messages in thread
From: 858585 jemmy @ 2017-04-20  7:59 UTC (permalink / raw)
  To: Fam Zheng; +Cc: qemu-devel, Kevin Wolf, Lidong Chen, qemu block, mreitz

On Thu, Apr 20, 2017 at 3:51 PM, Fam Zheng <famz@redhat.com> wrote:
> On Thu, 04/20 12:04, jemmy858585@gmail.com wrote:
>> From: Lidong Chen <lidongchen@tencent.com>
>>
>> When use old style option like -o backing_file, img_convert
>> continue run when bs_n > 1, this patch fix this bug.
>>
>> Signed-off-by: Lidong Chen <lidongchen@tencent.com>
>> ---
>>  qemu-img.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/qemu-img.c b/qemu-img.c
>> index b220cf7..c673aef 100644
>> --- a/qemu-img.c
>> +++ b/qemu-img.c
>> @@ -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 =
>> --
>> 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?
moving that down is ok.
but will exit later if use -B option.
which way do you think better?


>
> Fam

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-img: check bs_n when use old style option
  2017-04-20  7:59   ` 858585 jemmy
@ 2017-04-20  8:11     ` Fam Zheng
  2017-04-20  8:16       ` 858585 jemmy
  0 siblings, 1 reply; 5+ messages in thread
From: Fam Zheng @ 2017-04-20  8:11 UTC (permalink / raw)
  To: 858585 jemmy; +Cc: qemu-devel, Kevin Wolf, Lidong Chen, qemu block, mreitz

On Thu, 04/20 15:59, 858585 jemmy wrote:
> On Thu, Apr 20, 2017 at 3:51 PM, Fam Zheng <famz@redhat.com> wrote:
> > On Thu, 04/20 12:04, jemmy858585@gmail.com wrote:
> >> From: Lidong Chen <lidongchen@tencent.com>
> >>
> >> When use old style option like -o backing_file, img_convert
> >> continue run when bs_n > 1, this patch fix this bug.
> >>
> >> Signed-off-by: Lidong Chen <lidongchen@tencent.com>
> >> ---
> >>  qemu-img.c | 7 +++++++
> >>  1 file changed, 7 insertions(+)
> >>
> >> diff --git a/qemu-img.c b/qemu-img.c
> >> index b220cf7..c673aef 100644
> >> --- a/qemu-img.c
> >> +++ b/qemu-img.c
> >> @@ -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 =
> >> --
> >> 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?
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-img: check bs_n when use old style option
  2017-04-20  8:11     ` Fam Zheng
@ 2017-04-20  8:16       ` 858585 jemmy
  0 siblings, 0 replies; 5+ messages in thread
From: 858585 jemmy @ 2017-04-20  8:16 UTC (permalink / raw)
  To: Fam Zheng; +Cc: qemu-devel, Kevin Wolf, Lidong Chen, qemu block, mreitz

On Thu, Apr 20, 2017 at 4:11 PM, Fam Zheng <famz@redhat.com> wrote:
> On Thu, 04/20 15:59, 858585 jemmy wrote:
>> On Thu, Apr 20, 2017 at 3:51 PM, Fam Zheng <famz@redhat.com> wrote:
>> > On Thu, 04/20 12:04, jemmy858585@gmail.com wrote:
>> >> From: Lidong Chen <lidongchen@tencent.com>
>> >>
>> >> When use old style option like -o backing_file, img_convert
>> >> continue run when bs_n > 1, this patch fix this bug.
>> >>
>> >> Signed-off-by: Lidong Chen <lidongchen@tencent.com>
>> >> ---
>> >>  qemu-img.c | 7 +++++++
>> >>  1 file changed, 7 insertions(+)
>> >>
>> >> diff --git a/qemu-img.c b/qemu-img.c
>> >> index b220cf7..c673aef 100644
>> >> --- a/qemu-img.c
>> >> +++ b/qemu-img.c
>> >> @@ -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 =
>> >> --
>> >> 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?
>> 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).
Thanks. i will submit this patch again.


>
> Fam

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-04-20  8:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-20  4:04 [Qemu-devel] [PATCH] qemu-img: check bs_n when use old style option jemmy858585
2017-04-20  7:51 ` Fam Zheng
2017-04-20  7:59   ` 858585 jemmy
2017-04-20  8:11     ` Fam Zheng
2017-04-20  8:16       ` 858585 jemmy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.