From: "Daniel P. Berrange" <berrange@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-block@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
qemu-devel@nongnu.org, "Max Reitz" <mreitz@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH v14 03/19] option: allow qemu_opts_to_qdict to merge repeated options
Date: Wed, 28 Sep 2016 14:44:11 +0100 [thread overview]
Message-ID: <20160928134411.GD15510@redhat.com> (raw)
In-Reply-To: <20160928093505.GI21583@redhat.com>
On Wed, Sep 28, 2016 at 10:35:05AM +0100, Daniel P. Berrange wrote:
> On Tue, Sep 27, 2016 at 05:03:17PM -0500, Eric Blake wrote:
> > On 09/27/2016 08:13 AM, Daniel P. Berrange wrote:
> > > If given an option string such as
> > >
> > > size=1024,nodes=10,nodes=4-5,nodes=1-2,policy=bind
> > >
> > > the qemu_opts_to_qdict() method will currently overwrite
> > > the values for repeated option keys, so only the last
> > > value is in the returned dict:
> > >
> > > size=1024
> > > nodes=1-2
> > > policy=bind
> > >
> > > This adds the ability for the caller to ask that the
> > > repeated keys be turned into list indexes:
> > >
> > > size=1024
> > > nodes.0=10
> > > nodes.1=4-5
> > > nodes.2=1-2
> > > policy=bind
> > >
> > > Note that the conversion has no way of knowing whether
> > > any given key is expected to be a list upfront - it can
> > > only figure that out when seeing the first duplicated
> > > key. Thus the caller has to be prepared to deal with the
> > > fact that if a key 'foo' is a list, then the returned
> > > qdict may contain either 'foo' (if only a single instance
> > > of the key was seen) or 'foo.NN' (if multiple instances
> > > of the key were seen).
> > >
> > > Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> > > ---
> >
> > If I'm not mistaken, this policy adds a new policy, but all existing
> > clients use the old policy, and the new policy is exercised only by the
> > testsuite additions. Might be useful to mention that in the commit
> > message, rather than making me read the whole commit before guessing that.
>
> Correct, this will only be used in combination with the
> later qdict_crumple method.
>
> > > +++ b/include/qemu/option.h
> > > @@ -125,7 +125,13 @@ void qemu_opts_set_defaults(QemuOptsList *list, const char *params,
> > > int permit_abbrev);
> > > QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
> > > Error **errp);
> > > -QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict);
> > > +typedef enum {
> > > + QEMU_OPTS_REPEAT_POLICY_LAST,
> > > + QEMU_OPTS_REPEAT_POLICY_LIST,
> >
> > Hmm. I suspect this subtle difference (one vowel) to be the source of
> > typo bugs. Can we come up with more obvious policy names, such as
> > LAST_ONLY vs. INTO_LIST? Except that doing that makes it harder to fit
> > 80 columns. So up to you if you want to ignore me here.
>
> I'll use POLICY_LAST and POLICY_ALL.
>
> > ERROR: an occurrence of a duplicate option is considered an error
>
> Yeah, sure can add that easily.
>
> > Also, while you turn 'foo=a,foo=b' into 'foo.0=a,foo.1=b', does your
> > code correctly handle the cases of 'foo.0=a,foo=b' and 'foo=a,foo.1=b'?
> > (And what IS the correct handling of those cases logically supposed to be?)
>
> I'd be inclined to say that is an error. We're only doing this
> hack to maintain compatibility with existing OptsVisitor
> semantics for repeated options, and the scenario you illustrate
> is not possible with OptsVisitor. So I say we keep it an error.
> Either use the old syntax or the new syntax, but not mix them
> ever.
Having looked at this again, I don't think this code should try to
detect 'foo.0=a,foo=b', because qemu_opts_to_qdict() is not placing
an semantic interpretation on the keys. Such semantics are defined
by the qdict_crumple() method, so that's where I'll have to do such
error detection.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|
next prev parent reply other threads:[~2016-09-28 13:44 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-27 13:13 [Qemu-devel] [PATCH v14 00/19] QAPI/QOM work for non-scalar object properties Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 01/19] qdict: implement a qdict_crumple method for un-flattening a dict Daniel P. Berrange
2016-09-27 21:22 ` Eric Blake
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 02/19] option: make parse_option_bool/number non-static Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 03/19] option: allow qemu_opts_to_qdict to merge repeated options Daniel P. Berrange
2016-09-27 22:03 ` Eric Blake
2016-09-28 9:35 ` Daniel P. Berrange
2016-09-28 13:44 ` Daniel P. Berrange [this message]
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 04/19] qapi: add trace events for visitor Daniel P. Berrange
2016-09-27 22:05 ` Eric Blake
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 05/19] qapi: rename QmpInputVisitor to QObjectInputVisitor Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 06/19] qapi: rename QmpOutputVisitor to QObjectOutputVisitor Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 07/19] qapi: don't pass two copies of TestInputVisitorData to tests Daniel P. Berrange
2016-09-27 22:10 ` Eric Blake
2016-09-27 22:12 ` Eric Blake
2016-09-28 9:35 ` Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 08/19] qapi: permit scalar type conversions in QObjectInputVisitor Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 09/19] qapi: permit auto-creating single element lists Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 10/19] qapi: permit auto-creating nested structs Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 11/19] qapi: add integer range support for QObjectInputVisitor Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 12/19] qapi: allow QObjectInputVisitor to be created with QemuOpts Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 13/19] qom: support non-scalar properties with -object Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 14/19] hmp: support non-scalar properties with object_add Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 15/19] numa: convert to use QObjectInputVisitor for -numa Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 16/19] block: convert crypto driver to use QObjectInputVisitor Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 17/19] acpi: convert to QObjectInputVisitor for -acpi parsing Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 18/19] net: convert to QObjectInputVisitor for -net/-netdev parsing Daniel P. Berrange
2016-09-27 13:13 ` [Qemu-devel] [PATCH v14 19/19] qapi: delete unused OptsVisitor code Daniel P. Berrange
2016-10-20 15:06 ` [Qemu-devel] [PATCH v14 00/19] QAPI/QOM work for non-scalar object properties Markus Armbruster
2016-10-20 15:14 ` Daniel P. Berrange
2016-10-21 9:35 ` Markus Armbruster
2016-10-21 9:38 ` Daniel P. Berrange
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=20160928134411.GD15510@redhat.com \
--to=berrange@redhat.com \
--cc=afaerber@suse.de \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--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 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.