From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>,
"Daniel P. Berrange" <berrange@redhat.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@gmail.com>,
qemu-devel@nongnu.org, "Andreas Färber" <afaerber@suse.de>,
"Max Reitz" <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v8 3/7] qapi: add a QmpInputVisitor that does string conversion
Date: Fri, 15 Jul 2016 10:27:13 -0600 [thread overview]
Message-ID: <57890EE1.4060901@redhat.com> (raw)
In-Reply-To: <87eg6udibp.fsf@dusky.pond.sub.org>
[-- Attachment #1: Type: text/plain, Size: 3022 bytes --]
On 07/15/2016 09:36 AM, Markus Armbruster wrote:
> "Daniel P. Berrange" <berrange@redhat.com> writes:
>
>> Currently the QmpInputVisitor assumes that all scalar
>> values are directly represented as their final types.
>> ie it assumes an 'int' is using QInt, and a 'bool' is
>> using QBool.
>>
>> This adds an alternative constructor for QmpInputVisitor
>> that will set it up such that it expects a QString for
>> all scalar types instead.
>>
>> This makes it possible to use QmpInputVisitor with a
>> QDict produced from QemuOpts, where everything is in
>> string format.
>>
>> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
>> ---
>> +Visitor *qmp_string_input_visitor_new(QObject *obj, bool strict);
>
> We have a QMP input visitor that isn't really about QMP, and a string
> visitor. You're adding a QMP string input visitor that's even less
> about QMP (using it with QMP would be wrong, in fact), and that is
> related to the string visitor only insofar as both parse strings.
> Differently, of course; this is QEMU.
>
> Can't think of a better name, and I'm running out of Friday.
>
Sounds like we might want a prereq patch that just does a global rename
of s/qmp-\(input-visitor\|output-visitor\)/qobj-\1/ through all affected
files. Since it really is a QObject visitor, the rename will make it
easier to give the new visitor a nicer name.
> Should we specify how strings are parsed?
>
> Do you actually need both strict = true and strict = false here?
I'd be fine if we just enforced that the new QObject-string parser is
always strict. Non-strict parsers should only be used where we are
worried about back-compat for hand-written code that knows how to deal
with unparsed keys (such as device_add, where we MUST accept arguments
not part of the QAPI schema, so long as we don't have a schema that
fully describes it).
>> static void qmp_input_optional(Visitor *v, const char *name, bool *present)
>> {
>> QmpInputVisitor *qiv = to_qiv(v);
>
> Separate callbacks result in cleaner code than what I reviewed last.
> Cleaner semantics, too: either all the scalars have sane types, or all
> are strings.
In other words, it forces us to strongly be tied to the input source,
where command line is strongly-typed to strings, and QMP is
strongly-typed to native types. It doesn't solve the problem of
netdev_add previously being loose and taking both types, but as we've
mentioned in other threads, we may not care (it may be sufficient to
state that the undocumented looseness of netdev_add is not worth
fixing); and Dan did have the nice followup proposal of adding yet
another callback with peek semantics that can then delegate to the
correct strongly-typed callback, rather than my approach that munged it
all into a single callback.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2016-07-15 16:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-14 14:03 [Qemu-devel] [PATCH v8 0/7] Provide a QOM-based authorization API Daniel P. Berrange
2016-07-14 14:03 ` [Qemu-devel] [PATCH v8 1/7] qdict: implement a qdict_crumple method for un-flattening a dict Daniel P. Berrange
2016-07-15 15:06 ` Markus Armbruster
2016-07-14 14:03 ` [Qemu-devel] [PATCH v8 2/7] option: make parse_option_bool/number non-static Daniel P. Berrange
2016-07-15 15:13 ` Markus Armbruster
2016-07-14 14:03 ` [Qemu-devel] [PATCH v8 3/7] qapi: add a QmpInputVisitor that does string conversion Daniel P. Berrange
2016-07-15 15:36 ` Markus Armbruster
2016-07-15 16:27 ` Eric Blake [this message]
2016-07-14 14:03 ` [Qemu-devel] [PATCH v8 4/7] qom: support arbitrary non-scalar properties with -object Daniel P. Berrange
2016-07-14 14:03 ` [Qemu-devel] [PATCH v8 5/7] util: add QAuthZ object as an authorization base class Daniel P. Berrange
2016-07-14 14:03 ` [Qemu-devel] [PATCH v8 6/7] util: add QAuthZSimple object type for a simple access control list Daniel P. Berrange
2016-07-14 14:03 ` [Qemu-devel] [PATCH v8 7/7] acl: delete existing ACL implementation 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=57890EE1.4060901@redhat.com \
--to=eblake@redhat.com \
--cc=afaerber@suse.de \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.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 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.