qemu/net
Eric Blake 32bafa8fdd qapi: Don't special-case simple union wrappers
Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type().  But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:

| struct q_obj_ImageInfoSpecificQCow2_wrapper {
|     ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
|     ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
|     ImageInfoSpecificKind type;
|     union { /* union tag is @type */
|         void *data;
|-        ImageInfoSpecificQCow2 *qcow2;
|-        ImageInfoSpecificVmdk *vmdk;
|+        q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+        q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
|     } u;
| };

Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation).  Using the implicit type
also lets us get rid of the simple_union_type() hack.

Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access.  The generated
qapi-visit.c code is also affected by the layout change:

|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
|     }
|     switch (obj->type) {
|     case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|-        visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+        visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
|         break;
|     case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|-        visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+        visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
|         break;
|     default:
|         abort();

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-03-18 10:29:26 +01:00
..
checksum.c net: check packet payload length 2016-03-08 15:34:18 +08:00
clients.h net: Permit incremental conversion of init functions to Error 2015-05-27 09:51:04 +01:00
dump.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
eth.c net: Clean up includes 2016-02-04 17:41:30 +00:00
filter-buffer.c filter-buffer: Add status_changed callback processing 2016-03-08 15:34:18 +08:00
filter.c filter: Add 'status' property for filter object 2016-03-08 15:34:18 +08:00
hub.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
hub.h net: fix qemu_flush_queued_packets() in presence of a hub 2013-02-27 16:10:23 +01:00
l2tpv3.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
Makefile.objs netfilter: add a netbuffer filter 2015-10-12 13:31:28 +08:00
net.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
netmap.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
queue.c net: Clean up includes 2016-02-04 17:41:30 +00:00
slirp.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
socket.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
tap_int.h tap: add VNET_LE/VNET_BE operations 2015-06-17 17:12:54 +02:00
tap-aix.c net: Clean up includes 2016-02-04 17:41:30 +00:00
tap-bsd.c net: Clean up includes 2016-02-04 17:41:30 +00:00
tap-haiku.c net: Clean up includes 2016-02-04 17:41:30 +00:00
tap-linux.c net: Clean up includes 2016-02-04 17:41:30 +00:00
tap-linux.h all: Clean up includes 2016-02-23 12:43:05 +00:00
tap-solaris.c net: Clean up includes 2016-02-04 17:41:30 +00:00
tap-win32.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
tap.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
util.c net: Clean up includes 2016-02-04 17:41:30 +00:00
util.h all: Clean up includes 2016-02-23 12:43:05 +00:00
vde.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
vhost-user.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00