From: Kevin Wolf <kwolf@redhat.com>
To: "Gabriel L. Somlo" <gsomlo@gmail.com>
Cc: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] help parsing qemu options
Date: Wed, 11 Mar 2015 14:17:04 +0100 [thread overview]
Message-ID: <20150311131704.GJ6628@noname.str.redhat.com> (raw)
In-Reply-To: <20150311125300.GQ1832@HEDWIG.INI.CMU.EDU>
Am 11.03.2015 um 13:53 hat Gabriel L. Somlo geschrieben:
> On Wed, Mar 11, 2015 at 08:40:46AM -0400, Gabriel L. Somlo wrote:
> > On Wed, Mar 11, 2015 at 12:59:40PM +0100, Kevin Wolf wrote:
> > >
> > > def_value_str exists in the current codebase, and it seems to take
> > > precedence when a different default is specified by the caller.
> >
> > So I've now added .def_value_str fields:
> >
> > static QemuOptsList qemu_foo_opts = {
> > .name = "foo",
> > .head = QTAILQ_HEAD_INITIALIZER(qemu_foo_opts.head),
> > .desc = {
> > {
> > .name = "name",
> > .type = QEMU_OPT_STRING,
> > .def_value_str = "abc",
> > }, {
> > .name = "file",
> > .type = QEMU_OPT_STRING,
> > .def_value_str = "xyz",
> > },
> > { /* end of list */ }
> > },
> > };
> >
> > but "-foo name,file" still results in qemu_opt_get(opts, "name")
> > returning "on", rather than "abc". Is that a bug, or am I missing
> > something, or doing something wrong ?
>
> Specifically, in qemu_opt_get() (in util/qemu-option.c:311)
> desc->def_value_str is only used if qemu_opt_find() returns NULL,
> which in my case does NOT happen ("on" is returned instead).
>
> That, in turn, probably happens because opts_do_parse()
> (in util/qemu-options.c:776) assumes that "option without value"
> is "probably a flag" :)
>
> Not sure we'd want to mess with that assumption, but that most likely
> means I don't get to use .def_value_str the way I thought I could :)
Indeed, setting a default value alone won't solve your problem. It might
help you with implementing the solution, though, which would involve
something like changing the meaning of valueless options to taking the
default and using "on" as the default for boolean values.
I haven't thought thoroughly about QemuOptsLists yet which accept any
option. They may still be a reason for the approach outlined above to
fail.
Kevin
prev parent reply other threads:[~2015-03-11 13:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-09 17:50 [Qemu-devel] help parsing qemu options Gabriel L. Somlo
2015-03-10 8:40 ` Markus Armbruster
2015-03-10 17:35 ` Gabriel L. Somlo
2015-03-11 7:52 ` Markus Armbruster
2015-03-11 11:59 ` Kevin Wolf
2015-03-11 12:40 ` Gabriel L. Somlo
2015-03-11 12:53 ` Gabriel L. Somlo
2015-03-11 13:17 ` Kevin Wolf [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150311131704.GJ6628@noname.str.redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=gsomlo@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).