qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 2/6] qemu-img create: Support multiple -o opt


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v2 2/6] qemu-img create: Support multiple -o options
Date: Thu, 20 Feb 2014 08:52:08 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

On 02/20/2014 07:57 AM, Kevin Wolf wrote:
> If you specified multiple -o options for qemu-img create, it would
> silently ignore all but the last one. This patch fixes the problem.
> 
> Now multiple -o options has the same meaning as having a single option
> with all settings in the order of their respective -o options.
> 
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
>  qemu-img.c | 24 ++++++++++++++++++------
>  1 file changed, 18 insertions(+), 6 deletions(-)

Much nicer than v1!

Reviewed-by: Eric Blake <address@hidden>

>          case 'o':
> -            options = optarg;
> +            if (!options) {
> +                options = g_strdup(optarg);
> +            } else {
> +                char *old_options = options;
> +                options = g_strdup_printf("%s,%s", options, optarg);
> +                g_free(old_options);
> +            }

Corner case:

Previously:

qemu-img create -f qcow2 -o backing_file=/dev/null, xyz 1M

creates xyz with a backing file of /dev/null and unspecified backing
format (and ignores the empty trailing option).

Now:

qemu-img create -f qcow2 -o backing_file=/dev/null, \
  -o backing_fmt=qcow2 xyz 1M

creates xyz with a backing file of '/dev/null,backing_fmt=qcow2' and
with an unspecified backing format (and NOT with a backing format of
qcow2).  Yikes!  What we thought was an empty trailing option instead
got turned into a literal comma in the backing_file option.

Maybe you should add a followup patch that errors out on trailing
commas, so that we don't end up creating ',,' in the concatenated
version.  And maybe patch get_opt_value() to detect and reject empty
trailing options as well.

But as this patch is already a strict improvement, it does not have to
be done in this commit.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]