From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
Peter Krempa <pkrempa@redhat.com>, Eric Blake <eblake@redhat.com>,
"Daniel P. Berrange" <berrange@redhat.com>
Subject: Re: [Qemu-devel] Non-flat command line option argument syntax
Date: Tue, 21 Mar 2017 09:40:26 +0100 [thread overview]
Message-ID: <87y3vzrpj9.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <87bmukmlau.fsf@dusky.pond.sub.org> (Markus Armbruster's message of "Thu, 02 Feb 2017 20:42:33 +0100")
For the record, we went with "either dotted keys or JSON" for -blockdev
in 2.9.
Certain uses of QAPI become problematic with dotted keys, because
(1) it's untyped except for inner tree nodes, and therefore can't
express numbers, boolean, null, empty list, empty object, and
(2) The keyval variant of the QObject input visitor (the thing returned
by qobject_input_visitor_new_keyval()) can't fully hide this.
I don't like this at all, but the whole non-flat command line argument
design has been an exercise in picking what I dislike least.
Example: object-add's use of 'any' for properties
QOM properties aren't specified in the QAPI schema (let's ignore the
question whether they should be here). object-add uses type 'any'
to take a dictionary of them. object-add obviously needs to do the
type checking itself. In C, type 'any' is QObject *.
If object-add examines the QObject directly, it now needs to know
whether it was made from dotted keys, so it can cope with dotted
keys' "everything's a string".
Probably the only sane way to do that is to use the appropriate
visitor. Perhaps we should represent 'any' as QObjectInputVisitor *
instead of QObject *.
Example: TCP service name / port number as alternate of string, number
We use string, just like getaddrinfo(): if the string is a decimal
number, it's a port number, else a service name.
An alternate of string and number would be more idiomatic QAPI
(let's ignore compatibility here, it's just an example). Works fine
with JSON. Breaks with dotted keys, because you always get the
alternate's string variant there.
Possible ways forward:
* When it breaks, fall back to JSON
Tolerable if it breaks pretty much only in obscure corner cases.
* More syntax
Add syntax to disambiguate the type (key sigils?). Has to be optional
for backward compatibility reasons. When omitting type information
breaks, you have to supply it, or fall back to JSON.
More syntax for use in obscure cases is about the last thing the QEMU
command line needs.
* More magic
Make the keyval variant of the QObject input visitor shift the
breakage to hopefully less common cases.
- Empty list magic
When the visitor is asked for a list, and the list's key wasn't
specified, return an empty list instead of failure. Unbreaks empty
list, breaks absent optional list.
- Alternate magic
When the visitor is asked for an alternate, pick the alternate's
variant based on the value rather than the type for scalar values
(the type is always 'str' then). Unbreaks alternates when this
picks the variant you want, breaks them when you really want 'str'.
- Possibly more
When the magic breaks, fall back to JSON.
More magic in the QEMU command line feels even worse to me than more
syntax.
prev parent reply other threads:[~2017-03-21 8:40 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-02 19:42 [Qemu-devel] Non-flat command line option argument syntax Markus Armbruster
2017-02-02 20:06 ` Eric Blake
2017-02-02 20:23 ` Eric Blake
2017-02-03 7:57 ` Markus Armbruster
2017-02-02 20:27 ` Dr. David Alan Gilbert
2017-02-03 7:50 ` Markus Armbruster
2017-02-03 16:57 ` Dr. David Alan Gilbert
2017-02-04 9:44 ` Markus Armbruster
2017-02-06 10:20 ` Dr. David Alan Gilbert
2017-02-03 20:02 ` [Qemu-devel] [Qemu-block] " Max Reitz
2017-02-04 9:45 ` Markus Armbruster
2017-02-04 10:03 ` [Qemu-devel] " Paolo Bonzini
2017-02-04 11:52 ` Markus Armbruster
2017-02-04 12:43 ` Paolo Bonzini
2017-02-03 10:03 ` Daniel P. Berrange
2017-02-03 11:13 ` Markus Armbruster
2017-02-03 12:37 ` Peter Krempa
2017-02-03 13:53 ` Markus Armbruster
2017-02-03 17:25 ` Richard W.M. Jones
2017-02-04 9:51 ` Markus Armbruster
2017-02-05 20:46 ` [Qemu-devel] [Qemu-block] " Max Reitz
2017-02-03 20:28 ` Max Reitz
2017-02-04 9:56 ` Markus Armbruster
2017-02-04 12:21 ` [Qemu-devel] " Fam Zheng
2017-02-04 12:44 ` Paolo Bonzini
2017-02-04 13:02 ` Fam Zheng
2017-02-04 13:35 ` Markus Armbruster
2017-02-04 14:10 ` Fam Zheng
2017-02-06 6:24 ` Markus Armbruster
2017-02-06 11:08 ` Daniel P. Berrange
2017-02-06 6:57 ` Markus Armbruster
2017-02-06 13:23 ` Kevin Wolf
2017-02-06 15:36 ` Markus Armbruster
2017-02-06 16:33 ` Daniel P. Berrange
2017-02-06 17:24 ` Markus Armbruster
2017-02-06 17:50 ` Daniel P. Berrange
2017-02-06 18:56 ` Markus Armbruster
2017-02-06 17:38 ` Paolo Bonzini
2017-02-06 18:12 ` Markus Armbruster
2017-02-06 21:52 ` Paolo Bonzini
2017-02-07 7:02 ` Markus Armbruster
2017-02-07 9:26 ` Kevin Wolf
2017-02-24 16:04 ` Markus Armbruster
2017-02-24 16:39 ` Daniel P. Berrange
2017-02-24 17:17 ` Eric Blake
2017-02-24 19:15 ` Markus Armbruster
2017-02-27 10:27 ` Markus Armbruster
2017-02-27 10:59 ` Kevin Wolf
2017-02-27 13:36 ` Markus Armbruster
2017-02-27 19:47 ` Eric Blake
2017-02-28 8:24 ` Markus Armbruster
2017-02-27 19:43 ` Eric Blake
2017-02-28 8:41 ` Markus Armbruster
2017-03-01 9:24 ` Markus Armbruster
2017-03-21 8:40 ` Markus Armbruster [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=87y3vzrpj9.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=pkrempa@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.