From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34866) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yug2D-00068b-KX for qemu-devel@nongnu.org; Tue, 19 May 2015 07:50:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yug27-0001AN-Rh for qemu-devel@nongnu.org; Tue, 19 May 2015 07:50:09 -0400 Received: from mail-wg0-x230.google.com ([2a00:1450:400c:c00::230]:33049) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yug27-00019W-Lx for qemu-devel@nongnu.org; Tue, 19 May 2015 07:50:03 -0400 Received: by wgjc11 with SMTP id c11so14716844wgj.0 for ; Tue, 19 May 2015 04:50:03 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <555B2366.3040604@redhat.com> Date: Tue, 19 May 2015 13:49:58 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1431352157-40283-1-git-send-email-pbonzini@redhat.com> <1431352157-40283-11-git-send-email-pbonzini@redhat.com> In-Reply-To: <1431352157-40283-11-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 10/31] vl: allow full-blown QemuOpts syntax for -global List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Markus Armbruster , lersek@redhat.com, kraxel@redhat.com, mst@redhat.com Markus, can you review this one? Thanks, Paolo On 11/05/2015 15:48, Paolo Bonzini wrote: > -global does not work for drivers that have a dot in their name, such as > cfi.pflash01. This is just a parsing limitation, because such globals > can be declared easily inside a -readconfig file. > > To allow this usage, support the full QemuOpts key/value syntax for -global > too, for example "-global driver=cfi.pflash01,property=secure,value=on". > The two formats do not conflict, because the key/value syntax does not have > a period before the first equal sign. > > Signed-off-by: Paolo Bonzini > --- > qdev-monitor.c | 18 +++++++++++------- > qemu-options.hx | 7 ++++++- > 2 files changed, 17 insertions(+), 8 deletions(-) > > diff --git a/qdev-monitor.c b/qdev-monitor.c > index 1d87f57..9f17c81 100644 > --- a/qdev-monitor.c > +++ b/qdev-monitor.c > @@ -822,15 +822,19 @@ int qemu_global_option(const char *str) > QemuOpts *opts; > int rc, offset; > > - rc = sscanf(str, "%63[^.].%63[^=]%n", driver, property, &offset); > - if (rc < 2 || str[offset] != '=') { > - error_report("can't parse: \"%s\"", str); > + rc = sscanf(str, "%63[^.=].%63[^=]%n", driver, property, &offset); > + if (rc == 2 && str[offset] == '=') { > + opts = qemu_opts_create(&qemu_global_opts, NULL, 0, &error_abort); > + qemu_opt_set(opts, "driver", driver, &error_abort); > + qemu_opt_set(opts, "property", property, &error_abort); > + qemu_opt_set(opts, "value", str + offset + 1, &error_abort); > + return 0; > + } > + > + opts = qemu_opts_parse(&qemu_global_opts, str, false); > + if (!opts) { > return -1; > } > > - opts = qemu_opts_create(&qemu_global_opts, NULL, 0, &error_abort); > - qemu_opt_set(opts, "driver", driver, &error_abort); > - qemu_opt_set(opts, "property", property, &error_abort); > - qemu_opt_set(opts, "value", str + offset + 1, &error_abort); > return 0; > } > diff --git a/qemu-options.hx b/qemu-options.hx > index ec356f6..43c9ee0 100644 > --- a/qemu-options.hx > +++ b/qemu-options.hx > @@ -171,11 +171,13 @@ Set parameter @var{arg} for item @var{id} of type @var{group}\n" > ETEXI > > DEF("global", HAS_ARG, QEMU_OPTION_global, > - "-global driver.prop=value\n" > + "-global driver.property=value\n" > + "-global driver=driver,property=property,value=value\n" > " set a global default for a driver property\n", > QEMU_ARCH_ALL) > STEXI > @item -global @var{driver}.@var{prop}=@var{value} > +@itemx -global driver=@var{driver},property=@var{property},value=@var{value} > @findex -global > Set default value of @var{driver}'s property @var{prop} to @var{value}, e.g.: > > @@ -186,6 +188,9 @@ qemu-system-i386 -global ide-drive.physical_block_size=4096 -drive file=file,if= > In particular, you can use this to set driver properties for devices which are > created automatically by the machine model. To create a device which is not > created automatically and set properties on it, use -@option{device}. > + > +The two syntaxes are equivalent. The longer one works for drivers whose name > +contains a dot. > ETEXI > > DEF("boot", HAS_ARG, QEMU_OPTION_boot, >