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 <kw...@redhat.com> > --- > qemu-img.c | 24 ++++++++++++++++++------ > 1 file changed, 18 insertions(+), 6 deletions(-)
Much nicer than v1! Reviewed-by: Eric Blake <ebl...@redhat.com> > 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
signature.asc
Description: OpenPGP digital signature