qemu/hw
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
..
9pfs all: Clean up includes 2016-02-23 12:43:05 +00:00
acpi module: Rename machine_init() to opts_init() 2016-03-16 15:54:23 -03:00
alpha loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
arm machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
audio all: Clean up includes 2016-02-23 12:43:05 +00:00
block blockdev: Split monitor reference from BB creation 2016-03-17 15:47:56 +01:00
bt hw: Clean up includes 2016-01-29 15:07:25 +00:00
char qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
core loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
cpu hw/intc/arm_gic.c: Implement GICv2 GICC_DIR 2016-03-04 11:30:22 +00:00
cris loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
display bcm2835_fb: add framebuffer device for Raspberry Pi 2016-03-16 17:42:18 +00:00
dma bcm2835_dma: add emulation of Raspberry Pi DMA controller 2016-03-16 17:42:18 +00:00
gpio ARM: PL061: Checking register r/w accesses to reserved area 2016-02-26 15:09:42 +00:00
i2c i.MX: Add missing descriptions in devices. 2016-03-16 17:42:18 +00:00
i386 kvm: x86: q35: Add support for -machine kernel_irqchip=split for q35 2016-03-15 18:23:33 +01:00
ide ahci: prohibit "restarting" the FIS or CLB engines 2016-02-10 13:29:40 -05:00
input qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
intc hw/intc: Add (new) ASPEED VIC device model 2016-03-16 17:42:18 +00:00
ipack hw: Clean up includes 2016-01-29 15:07:25 +00:00
ipmi ipmi: add some local variables in ipmi_sdr_init 2016-03-11 16:59:13 +02:00
isa ich9lpc: fix typo 2016-03-11 16:45:21 +02:00
lm32 machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
m68k loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
mem qapi: Don't special-case simple union wrappers 2016-03-18 10:29:26 +01:00
microblaze loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
mips machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
misc bcm2835_property: implement framebuffer control/configuration properties 2016-03-16 17:42:18 +00:00
moxie loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
net i.MX: Add missing descriptions in devices. 2016-03-16 17:42:18 +00:00
nvram fw_cfg: expose control register size in fw_cfg.h 2016-03-08 10:46:30 +01:00
openrisc loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
pci msi_supported -> msi_nonbroken 2016-03-11 16:45:21 +02:00
pci-bridge pxb: cleanup 2016-03-11 16:59:12 +02:00
pci-host loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
pcmcia hw: Clean up includes 2016-01-29 15:07:25 +00:00
ppc machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
s390x machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
scsi scsi-bus: Remove tape command from scsi_req_xfer 2016-03-07 17:56:23 +01:00
sd sd: Fix "info qtree" on boards with SD cards 2016-03-16 17:42:19 +00:00
sh4 sh4: Clean up includes 2016-01-29 15:07:24 +00:00
smbios module: Rename machine_init() to opts_init() 2016-03-16 15:54:23 -03:00
sparc machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
sparc64 machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
ssi hw: Clean up includes 2016-01-29 15:07:25 +00:00
timer hw/timer: Add ASPEED timer device model 2016-03-16 17:42:18 +00:00
tpm hw: Clean up includes 2016-01-29 15:07:25 +00:00
tricore loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
unicore32 unicore: Clean up includes 2016-01-29 15:07:22 +00:00
usb usb-redirect: Avoid double free of data 2016-02-29 11:45:26 +01:00
vfio vfio: Eliminate vfio_container_ioctl() 2016-03-16 09:55:11 +11:00
virtio virtio-pci: call pci reset variant when guest requests reset. 2016-03-11 16:45:21 +02:00
watchdog watchdog/diag288: avoid race condition on expired watchdog 2016-03-01 12:15:28 +01:00
xen xen: drop XenXC and associated interface wrappers 2016-02-10 12:01:24 +00:00
xenpv xen: Clean up includes 2016-01-29 15:07:23 +00:00
xtensa machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
Makefile.objs Add a base IPMI interface 2015-12-22 18:39:19 +02:00