Eric Blake <ebl...@redhat.com> writes: > We have two issues with our qapi union layout: > 1) Even though the QMP wire format spells the tag 'type', the > C code spells it 'kind', requiring some hacks in the generator. > 2) The C struct uses an anonymous union, which places all tag > values in the same namespace as all non-variant members. This > leads to spurious collisions if a tag value matches a QMP name. > > This patch is the back end for a series that converts to a > saner qapi union layout. Now that all clients have been > converted to use 'type' and 'obj->u.value', we can drop the > temporary support for 'kind' and 'obj->value', and undo the > temporary restriction against 'u' as a branch name. > > Given a simple union qapi type: > > { 'union':'Foo', 'data': { 'a':'int', 'b':'bool' } } > > this is the overall effect, when compared to the state before > this series of patches: > > | struct Foo { > |- FooKind kind; > |- union { /* union tag is @kind */ > |+ FooKind type; > |+ union { /* union tag is @type */ > | void *data; > | int64_t a; > | bool b; > |- }; > |+ } u; > | }; > > Note, however, that we do not rename the generated enum, which > is still 'FooKind'. A further patch could generate implicit > enums as 'FooType', but that causes more churn to C code, and > gets harder since the generator already reserved the '*Kind' > namespace, but there are already QMP constructs with '*Type' > naming which means we cannot easily reserve it for qapi. > Signed-off-by: Eric Blake <ebl...@redhat.com>
If you edit the commit message of PATCH 07, make sure to edit this one to match. Patch looks good.