From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH v7 07/15] qapi: Implement boxed types for commands/events
Date: Tue, 14 Jun 2016 11:22:51 -0600 [thread overview]
Message-ID: <57603D6B.5020900@redhat.com> (raw)
In-Reply-To: <87ziqnaiz2.fsf@dusky.pond.sub.org>
[-- Attachment #1: Type: text/plain, Size: 4629 bytes --]
On 06/14/2016 09:27 AM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
>
>> Turn on the ability to pass command and event arguments in
>> a single boxed parameter. For structs, it makes it possible
>> to pass a single qapi type instead of a breakout of all
>> struct members; for unions, it is now possible to use a
>> union as the data for a command or event.
>>
>> Generated code is unchanged, as long as no client uses the
>> new feature.
>>
>> @@ -1640,12 +1652,13 @@ extern const char *const %(c_name)s_lookup[];
>>
>>
>> def gen_params(arg_type, box, extra):
>> - if not arg_type:
>> + if not arg_type or arg_type.is_empty():
>> return extra
>
> When arg_type is empty, box gets ignored. That's not wrong, but I'd
> skin this cat differently: when box=true, pass a single arg_type
> argument, no matter what the type is.
Except that we don't have a visit function generated for the 'q_empty'
type; I'm worried that coming up with the right arg_type for an empty
box may be difficult.
>> +++ b/tests/test-qmp-commands.c
>> @@ -60,6 +60,18 @@ QObject *qmp_guest_sync(QObject *arg, Error **errp)
>> return arg;
>> }
>>
>> +void qmp_boxed_empty(Error **errp)
>> +{
>> +}
>
> Demontrates that 'box': true with an empty type isn't boxed.
In other words, an empty type takes precedence over 'box':true, because
there is nothing to be passed.
I could go the other direction and make it a hard error to use
'box':true on an empty type, if that would be conceptually cleaner.
>>
>> +By default, the generator creates a marshalling function that converts
>> +an input QDict into a function call implemented by the user, and
>
> Well, the called function is implemented by the user.
>
>> +declares a prototype for the user's function which has a parameter for
>> +each member of the argument struct, including boolean arguments that
>> +describe whether optional arguments were provided. But if the QAPI
>> +description includes the key 'box' with the boolean value true, the
>> +user call prototype will have only a single parameter for the overall
>> +generated C structure. The 'box' key is required in order to use a
>> +union as an input argument, since it is not possible to list all
>> +members of the union as separate parameters.
>> +
>
> Neglects to mention that 'data' is less restricted with 'box': true.
>
> Suggest:
>
> The generator emits a prototype for the user's function implementing
> the command. Normally, 'data' is or names a struct type, and its
> members are passed as separate arguments to this function. If the
> command definition includes a key 'box' with the boolean value true,
> then the arguments are passed to the function as a single pointer to
> the QAPI type generated for 'data'. 'data' may name an arbitrary
> complex type then.
Or maybe arbitrary non-empty complex type, depending on what we decide
above. And maybe I still need to make it clear that when using
'box':true, an anonymous type is no longer permitted.
>
> This still glosses over the has_ arguments, but it's no worse than
> before.
>
> Only then mention the marshalling:
>
> The generator emits a marshalling function that extracts arguments
> for the user's function out of an input QDict, calls the user's
> function, and if it succeeded, builds an output QObject from its
> return value.
Sure, I can reword along those lines. (I may not state it enough, but
thanks for your wordsmithing help).
>> @@ -147,13 +150,14 @@
>> { 'struct': 'EventStructOne',
>> 'data': { 'struct1': 'UserDefOne', 'string': 'str', '*enum2': 'EnumOne' } }
>>
>> -{ 'event': 'EVENT_A' }
>> +{ 'event': 'EVENT_A', 'box': true }
>
> This is case "empty".
>
> Separate tests for both values of box would be cleaner, even though they
> produce the exact same result. If we decide to obey box even with empty
> types, they don't.
>
Or, if we decide to forbid 'box':true on an empty type, then this needs
tweaking anyway.
>> { 'event': 'EVENT_B',
>> 'data': { } }
>> { 'event': 'EVENT_C',
>> 'data': { '*a': 'int', '*b': 'UserDefOne', 'c': 'str' } }
>> { 'event': 'EVENT_D',
>> 'data': { 'a' : 'EventStructOne', 'b' : 'str', '*c': 'str', '*enum3': 'EnumOne' } }
>> +{ 'event': 'EVENT_E', 'box': true, 'data': 'UserDefZero' }
>
> This is case "struct".
>
> Missing: case "union".
>
--
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-06-14 17:22 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-20 22:40 [Qemu-devel] [PATCH v7 00/15] qapi netdev_add introspection (post-introspection cleanups subset F) Eric Blake
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 01/15] qapi: Consolidate object visitors Eric Blake
2016-06-14 12:35 ` Markus Armbruster
2016-06-16 14:46 ` Markus Armbruster
2016-06-16 17:20 ` Eric Blake
2016-06-17 7:39 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 02/15] net: use Netdev instead of NetClientOptions in client init Eric Blake
2016-06-14 13:11 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 03/15] qapi: Require all branches of flat union enum to be covered Eric Blake
2016-06-14 13:24 ` Markus Armbruster
2016-06-14 13:46 ` Eric Blake
2016-06-28 1:52 ` Eric Blake
2016-06-28 7:57 ` Markus Armbruster
2016-07-03 2:34 ` Eric Blake
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 04/15] qapi: Hide tag_name data member of variants Eric Blake
2016-06-14 13:32 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 05/15] qapi: Add type.is_empty() helper Eric Blake
2016-06-14 14:01 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 06/15] qapi: Plumb in 'box' to qapi generator lower levels Eric Blake
2016-06-14 14:39 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 07/15] qapi: Implement boxed types for commands/events Eric Blake
2016-06-14 15:27 ` Markus Armbruster
2016-06-14 17:22 ` Eric Blake [this message]
2016-06-15 6:22 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 08/15] block: Simplify block_set_io_throttle Eric Blake
2016-05-24 15:21 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2016-06-14 15:34 ` [Qemu-devel] " Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 09/15] block: Simplify drive-mirror Eric Blake
2016-06-14 15:42 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 10/15] qapi-event: Reduce chance of collision with event data Eric Blake
2016-06-14 16:28 ` Markus Armbruster
2016-06-16 12:25 ` Markus Armbruster
2016-06-28 3:20 ` Eric Blake
2016-06-28 8:06 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 11/15] qapi: Change Netdev into a flat union Eric Blake
2016-06-16 13:15 ` Markus Armbruster
2016-06-16 14:35 ` Eric Blake
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 12/15] net: Use correct type for bool flag Eric Blake
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 13/15] net: Complete qapi-fication of netdev_add Eric Blake
2016-06-16 13:40 ` Markus Armbruster
2016-07-02 22:58 ` Eric Blake
2016-07-04 13:46 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 14/15] qapi: Allow anonymous branch types in flat union Eric Blake
2016-06-16 14:33 ` Markus Armbruster
2016-07-01 22:59 ` Eric Blake
2016-07-04 13:13 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 15/15] schema: Drop pointless empty type CpuInfoOther Eric Blake
2016-05-20 22:59 ` [Qemu-devel] [PATCH v7 00/15] qapi netdev_add introspection (post-introspection cleanups subset F) Eric Blake
2016-06-16 14:57 ` Markus Armbruster
2016-06-28 18:14 ` Eric Blake
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=57603D6B.5020900@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=mdroth@linux.vnet.ibm.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).