summary refs log tree commit diff stats
path: root/tests/test-qmp-output-visitor.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2015-10-26 16:34:52 -0600
committerMarkus Armbruster <armbru@redhat.com>2015-11-02 08:30:27 +0100
commit150d0564a4c626642897c748f7906260a13c14e1 (patch)
tree64fbd22c593e04242d50b5d084d4c9d0c2074fcf /tests/test-qmp-output-visitor.c
parentf51d8fab44b231aa299d8de24cfdf9ba41ef4a21 (diff)
downloadfocaccia-qemu-150d0564a4c626642897c748f7906260a13c14e1.tar.gz
focaccia-qemu-150d0564a4c626642897c748f7906260a13c14e1.zip
qapi-visit: Convert to new qapi union layout
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 non-variant
member's name.

Make the conversion to the new layout for qapi-visit.py.

Generated code changes look like:

|@@ -4912,16 +4912,16 @@ void visit_type_MemoryDeviceInfo(Visitor
|     if (!*obj) {
|         goto out_obj;
|     }
|-    visit_type_MemoryDeviceInfoKind(v, &(*obj)->kind, "type", &err);
|+    visit_type_MemoryDeviceInfoKind(v, &(*obj)->type, "type", &err);
|     if (err) {
|         goto out_obj;
|     }
|-    if (!visit_start_union(v, !!(*obj)->data, &err) || err) {
|+    if (!visit_start_union(v, !!(*obj)->u.data, &err) || err) {
|         goto out_obj;
|     }
|-    switch ((*obj)->kind) {
|+    switch ((*obj)->type) {
|     case MEMORY_DEVICE_INFO_KIND_DIMM:
|-        visit_type_PCDIMMDeviceInfo(v, &(*obj)->dimm, "data", &err);
|+        visit_type_PCDIMMDeviceInfo(v, &(*obj)->u.dimm, "data", &err);
|         break;
|     default:
|         abort();
|@@ -4930,7 +4930,7 @@ out_obj:
|     error_propagate(errp, err);
|     err = NULL;
|     if (*obj) {
|-        visit_end_union(v, !!(*obj)->data, &err);
|+        visit_end_union(v, !!(*obj)->u.data, &err);
|     }
|     error_propagate(errp, err);
|     err = NULL;

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1445898903-12082-14-git-send-email-eblake@redhat.com>
[Commit message tweaked slightly]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'tests/test-qmp-output-visitor.c')
0 files changed, 0 insertions, 0 deletions