qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

qapi-event: Simplify visit of non-implicit data

Commit 7ce106a9 documented why we don't generated a visit_type_FOO()
for implicit types; and therefore events with an anonymous type for
'data' have to open-code a visit. Note that the open-coded visit in
qapi-event.c is slightly different from what is done in
qapi-visit.c for normal types, in part because we don't have to
check for *obj being NULL or free things on error. But where the
type is not implicit, it is nicer to reuse the normal visit instead
of open-coding a duplicate.

At the moment, the only event with a non-implicit 'data' is in the
testsuite, where test-qapi-event.c changes as follows:

|@@ -155,6 +155,7 @@ void qapi_event_send___org_qemu_x_event(
| __org_qemu_x_Struct param = {
| __org_qemu_x_member1, (char *)__org_qemu_x_member2, has_q_wchar_t, q_wchar_t
| };
|+ __org_qemu_x_Struct *arg = &param;
|
| emit = qmp_event_get_func_emit();
| if (!emit) {
|@@ -164,16 +165,7 @@ void qapi_event_send___org_qemu_x_event(
| qmp = qmp_event_build_dict("__ORG.QEMU_X-EVENT");
|
| v = qmp_output_visitor_new(&obj);
|-
|- visit_start_struct(v, "__ORG.QEMU_X-EVENT", NULL, 0, &err);
|- if (err) {
|- goto out;
|- }
|- visit_type___org_qemu_x_Struct_members(v, &param, &err);
|- if (!err) {
|- if (!err) {
|- visit_check_struct(v, &err);
|- }
|- visit_end_struct(v, NULL);
|+ visit_type___org_qemu_x_Struct(v, "__ORG.QEMU_X-EVENT", &arg, &err);
| if (err) {
| goto out;
| }

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1468468228-27827-8-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>

authored by

Eric Blake and committed by
Markus Armbruster
4d0b268f fa274ed6

+17 -2
+17 -2
scripts/qapi-event.py
··· 49 49 50 50 }; 51 51 ''') 52 + if not typ.is_implicit(): 53 + ret += mcgen(''' 54 + %(c_name)s *arg = &param; 55 + ''', 56 + c_name=typ.c_name()) 52 57 return ret 53 58 54 59 ··· 91 96 if arg_type and not arg_type.is_empty(): 92 97 ret += mcgen(''' 93 98 v = qmp_output_visitor_new(&obj); 99 + ''') 100 + if not arg_type.is_implicit(): 101 + ret += mcgen(''' 102 + visit_type_%(c_name)s(v, "%(name)s", &arg, &err); 103 + ''', 104 + name=name, c_name=arg_type.c_name()) 105 + else: 106 + ret += mcgen(''' 94 107 95 108 visit_start_struct(v, "%(name)s", NULL, 0, &err); 96 109 if (err) { ··· 101 114 visit_check_struct(v, &err); 102 115 } 103 116 visit_end_struct(v, NULL); 117 + ''', 118 + name=name, c_name=arg_type.c_name()) 119 + ret += mcgen(''' 104 120 if (err) { 105 121 goto out; 106 122 } 107 123 108 124 visit_complete(v, &obj); 109 125 qdict_put_obj(qmp, "data", obj); 110 - ''', 111 - name=name, c_name=arg_type.c_name()) 126 + ''') 112 127 113 128 ret += mcgen(''' 114 129 emit(%(c_enum)s, qmp, &err);