On 08/26/2015 08:41 AM, Markus Armbruster wrote:
> Only reviewing the QAPI part.
> 
> Yang Hongyang <yan...@cn.fujitsu.com> writes:
> 

> Let's make this a flat union instead, to reduce nesting, and therefore
> memory allocations and indirections.  Something like
> 
> { 'enum': 'NetFilterType',
>   'data': [] }
> 
> { 'struct': NetFilterBase',
>   'data': {
>       'id':   'str',
>       'netdev': 'str',
>       '*chain': 'str',
>       'type': 'NetFilterType'
> 
> { 'union': 'NetFilter',
>   'base': 'NetFilterBase',
>   'discriminator': 'type',
>   'data': {
>   }
> }
> 
> I hope to reduce the notational overhead of such flat unions in the near
> future.
> 
> Not sure empty unions actually work.  If they don't, you can either
> squash adding members into this patch, or add a dummy member, and drop
> it when you add the real ones.

The generator handles an empty union without compilation error, but
creates C code that will always abort() if the union is passed on the
wire.  I have pending patches on top of Markus' that outlaw an empty union:

[uggh: https://lists.gnu.org/archive/html/qemu-devel/ is hosed right
now, and it's harder to find messages on other archivers...]

http://thread.gmane.org/gmane.comp.emulators.qemu/356265/focus=356258
http://thread.gmane.org/gmane.comp.emulators.qemu/356265/focus=356294

so a dummy member for now is a reasonable compromise.

-- 
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