Received: from eggs.gnu.org ([2001:4830:134:3::10]:53929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpHC6-0002SM-OA for qemu-devel@nongnu.org; Thu, 22 Oct 2015 10:50:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpHC1-0000n4-LN for qemu-devel@nongnu.org; Thu, 22 Oct 2015 10:50:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41243) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpHC1-0000mu-GX for qemu-devel@nongnu.org; Thu, 22 Oct 2015 10:50:13 -0400 From: Markus Armbruster References: <1444968943-11254-1-git-send-email-eblake@redhat.com> <1444968943-11254-17-git-send-email-eblake@redhat.com> Date: Thu, 22 Oct 2015 16:50:10 +0200 In-Reply-To: <1444968943-11254-17-git-send-email-eblake@redhat.com> (Eric Blake's message of "Thu, 15 Oct 2015 22:15:41 -0600") Message-ID: <871tcnx8il.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v9 16/17] qapi: Finish converting to new qapi union layout List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, Michael Roth Eric Blake 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 If you edit the commit message of PATCH 07, make sure to edit this one to match. Patch looks good.