qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH RFC v3 30/32] qapi: New QMP command query-schema


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH RFC v3 30/32] qapi: New QMP command query-schema for QMP schema introspection
Date: Mon, 24 Aug 2015 07:07:34 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0

On 08/24/2015 05:30 AM, Markus Armbruster wrote:

>> We mentioned moving this into its own patch.  In particular, I looked at
>> what it would take to allow anonymous structs for flat union types:
>>
>> { 'union': 'Flat', 'base': 'Base',
>>   'discriminator': 'type',
>>   'data': { 'branch1': {},

This one is particularly handy - it would avoid the need to create dummy
types like 'Abort' that exist solely to satisfy the current qapi grammar.

>>             'branch2': { 'integer': 'int' } } }

This one is a bit harder to justify, but may still be useful.

> 
> We used to support inline structs in a few places, but dropped it
> (commit 6b5abc7).  Do we really want to add them back in other places?

We dropped nested structs, not anonymous structs.

For comparison, here's an anonymous command struct:

{ 'command': 'foo', 'data': { 'i': 'int' } }

vs. the corresponding named version:

{ 'struct': 'Foo', 'data': { 'i': 'int' } }
{ 'command': 'foo', 'data': 'Foo' }

Where things would NOT be allowed due to our prohibition of nested
structs is:

{ 'union': 'Flat', 'base': 'Base', 'discriminator': 'type',
  'data': { 'okay': 'str', 'bad': { 'i': 'int' } } }

> 
> Both Abort and ChardevDummy exist only because you need a type to
> declare a simple union case.  I'd like to explore cleaning up the
> convoluted union syntax first.  If we then still have a need for empty
> structs, we can consider optimizing them.

And that's where my patches were headed - by allowing a dict instead of
a type name for the branches of a flat union, the syntax for flat unions
becomes simpler, and allows us to sanely represent a
"no-additional-members" variant without needing 'Abort' as an empty type.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]