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: Mon, 06 Feb 2017 07:57:20 +0100 [thread overview]
Message-ID: <87vasnu7qn.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")
Markus Armbruster <armbru@redhat.com> writes:
[...]
> === Structured values ===
>
> The dotted key convention messes with KEY syntax to permit structured
> values. Works, but the more conventional way to support structured
> values is a syntax for structured values.
>
> An obvious one is to use { KEY=VALUE, ...} for objects, and [ VALUE,
> ... ] for arrays. Looks like this:
>
> -drive 'driver=quorum,
> child=[{ driver=file, filename=disk1.img },
> { driver=host_device, filename=/dev/sdb },
> { driver=nbd, host=localhost } ]'
>
> Again, lines broken and indented for legibility; you need to join them
> for actual use.
>
> There's a syntactic catch, though: a value of the form [ ... ] can
> either be an array or a string. Which one it is depends on the type of
> the key. To parse this syntax, you need to know the types, unlike JSON
> or traditional QemuOpts. Unless we outlaw strings starting with '{' or
> '[', which feels impractical.
The parser having to know the types obviously precludes a design where a
simple parser feeds into a type-aware visitor, which is how the JSON ->
QObject -> QAPI pipeline works.
Perhaps less obviously, it even precludes a design where the parser is
derived from the QAPI schema to make it type-aware: the 'any' type
spoils that.
Consider -object/object-add and -device/device_add. These take a few
statically known parameters such as "id". Any additional parameters get
collected in a dictionary. The schema represents it as value of type
'any'. The code using this dictionary value matches its entries against
QOM properties.
To parse these additional parameters, knowing the (compile-time static)
schema isn't sufficient. You also need to know the type of the QOM
property they'll get matched to at run-time.
This is a special case. For the general case, you need to know how code
is going to use the value. You generally can't know that until it's
done, so we'd have to parse lazily. Thanks, but no thanks.
> But wait, there's another syntactic catch: in traditional QemuOpts, a
> value ends at the next unescaped ',' or '\0'. Inside an object, it now
> also ends at the next unescaped '}', and inside an array, at the next
> unescaped ']'. Or perhaps at the next space (the example above assumes
> it does). That means we either have to provide a way to escape '}', ']'
> and space, or find another way to delimit string values, say require '"'
> around strings whenever the string contains "funny" characters.
>
> So, if escaped ',' wasn't ugly and confusing enough for you...
>
> === Comparison ===
>
> In my opinion, dotted keys are weird and ugly, but at least they don't
> add to the quoting mess. Structured values look better, except when
> they do add to the quoting mess.
>
> I'm having a hard time deciding which one I like less :)
>
> Opinions? Other ideas?
>
>
>
>
> [1] [PATCH v14 00/21] QAPI/QOM work for non-scalar object properties
> (actually v15)
> Message-Id: <1475246744-29302-1-git-send-email-berrange@redhat.com>
> http://lists.gnu.org/archive/html/qemu-devel/2016-09/msg08238.html
>
> [2] [RFC PATCH] block: Crude initial implementation of -blockdev
> Message-Id: <1485968933-9162-1-git-send-email-armbru@redhat.com>
> http://lists.gnu.org/archive/html/qemu-devel/2017-02/msg00182.html
>
> [3] Message-ID: <87h989ncse.fsf@dusky.pond.sub.org>
> http://lists.gnu.org/archive/html/qemu-devel/2016-10/msg04046.html
next prev parent reply other threads:[~2017-02-06 6:57 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 [this message]
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
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=87vasnu7qn.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.