qemu-e2k/block
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
..
accounting.c
archipelago.c
backup.c backup: Use Bitmap to replace "s->bitmap" 2016-03-14 17:35:05 +01:00
blkdebug.c
blkverify.c
block-backend.c block: Use blk_co_pwritev() in blk_co_write_zeroes() 2016-03-17 16:30:00 +01:00
bochs.c
cloop.c
commit.c
curl.c curl: add support for HTTP authentication parameters 2016-02-29 14:54:31 -05:00
dirty-bitmap.c block: Move block dirty bitmap code to separate files 2016-03-14 17:35:05 +01:00
dmg.c
gluster.c
io.c block: Pull up blk_read_unthrottled() implementation 2016-03-17 15:47:57 +01:00
iscsi.c iscsi: add support for getting CHAP password via QCryptoSecret API 2016-02-29 14:54:31 -05:00
linux-aio.c
Makefile.objs block: Move block dirty bitmap code to separate files 2016-03-14 17:35:05 +01:00
mirror.c mirror: Add mirror_wait_for_io 2016-02-29 14:54:31 -05:00
nbd-client.c nbd: enable use of TLS with NBD block driver 2016-02-16 17:16:33 +01:00
nbd-client.h nbd: enable use of TLS with NBD block driver 2016-02-16 17:16:33 +01:00
nbd.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
nfs.c block/nfs: add support for setting debug level 2016-02-29 14:54:30 -05:00
null.c
parallels.c blockdev: Split monitor reference from BB creation 2016-03-17 15:47:56 +01:00
qapi.c block/qapi: Include empty drives in query-blockstats 2016-03-14 16:46:42 +01:00
qcow2-cache.c
qcow2-cluster.c
qcow2-refcount.c
qcow2-snapshot.c
qcow2.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
qcow2.h
qcow.c blockdev: Split monitor reference from BB creation 2016-03-17 15:47:56 +01:00
qed-check.c
qed-cluster.c
qed-gencb.c
qed-l2-cache.c
qed-table.c
qed.c blockdev: Split monitor reference from BB creation 2016-03-17 15:47:56 +01:00
qed.h
quorum.c quorum: Emit QUORUM_REPORT_BAD for reads in fifo mode 2016-03-17 16:43:30 +01:00
raw_bsd.c
raw-aio.h
raw-posix.c
raw-win32.c
rbd.c rbd: add support for getting password from QCryptoSecret object 2016-02-29 14:54:30 -05:00
sheepdog.c blockdev: Split monitor reference from BB creation 2016-03-17 15:47:56 +01:00
snapshot.c
ssh.c
stream.c
throttle-groups.c
vdi.c blockdev: Split monitor reference from BB creation 2016-03-17 15:47:56 +01:00
vhdx-endian.c
vhdx-log.c
vhdx.c blockdev: Split monitor reference from BB creation 2016-03-17 15:47:56 +01:00
vhdx.h
vmdk.c qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
vpc.c blockdev: Split monitor reference from BB creation 2016-03-17 15:47:56 +01:00
vvfat.c
win32-aio.c
write-threshold.c