qapi: add #if pre-processor conditions to generated code (part 3)
v2 cover qapi: add #if pre-processor conditions to generated code (part 3)
Marc-André posted v1 that relies on a QAPI schema language extension 'top-unit' to permit splitting the generated code. Here is his cover letter:
The thrid and last part (of "[PATCH v2 00/54] qapi: add #if pre-processor conditions to generated code") is about adding schema conditions based on the target.
For now, the qapi code is compiled in common objects (common to all targets). This makes it impossible to add #if TARGET_ARM for example.
The patch "RFC: qapi: learn to split the schema by 'top-unit'" proposes to split the schema by "top-unit", so that generated code can be built either in common objects or per-target. That patch is a bit rough, I would like to get some feedback about the approach before trying to improve it. The following patches demonstrate usage of target-based #if conditions, and getting rid of the qmp_unregister_command() hack.
We already have a way to split generated code: QAPI modules. I took the liberty to rework Marc-André's series to use a target module instead. Less code, no change to the QAPI language.
One of the patches (marked WIP) is a total hack. Fixable, but I want to get this out for discussion first.
Marc-André Lureau (9):
build-sys: move qmp-introspect per target
qapi: make rtc-reset-reinjection and SEV depend on TARGET_I386
qapi: make s390 commands depend on TARGET_S390X target.json: add a note about query-cpu* not being s390x-specific
qapi: make query-gic-capabilities depend on TARGET_ARM
qapi: make query-cpu-model-expansion depend on s390 or x86
qapi: make query-cpu-definitions depend on specific targets
qapi: remove qmp_unregister_command()
qapi: move RTC_CHANGE to the target schema
Markus Armbruster (6):
qapi: Belatedly update docs for commit 9c2f56e9f9d
qapi: Eliminate indirection through qmp_event_get_func_emit()
qapi: Generate QAPIEvent stuff into separate files WIP
qapi: New module target.json
Revert "qapi-events: add 'if' condition to implicit event enum"
qmp: Deprecate query-events in favor of query-qmp-schema
Makefile | 1 + Makefile.objs | 22 +- Makefile.target | 12 + docs/devel/qapi-code-gen.txt | 12 +- hw/ppc/spapr_rtc.c | 2 +- hw/s390x/s390-skeys.c | 2 +- hw/timer/mc146818rtc.c | 4 +- include/qapi/qmp-event.h | 6 - include/qapi/qmp/dispatch.h | 1 - include/sysemu/arch_init.h | 11 - monitor.c | 92 +---- qapi/misc.json | 485 +--------------------- qapi/qapi-schema.json | 1 + qapi/qmp-event.c | 12 - qapi/qmp-registry.c | 8 - qapi/target.json | 514 ++++++++++++++++++++++++ qemu-deprecated.texi | 5 + qmp.c | 26 -- scripts/qapi/events.py | 51 ++- stubs/Makefile.objs | 4 - stubs/arch-query-cpu-def.c | 11 - stubs/arch-query-cpu-model-baseline.c | 13 - stubs/arch-query-cpu-model-comparison.c | 13 - stubs/arch-query-cpu-model-expansion.c | 13 - stubs/monitor.c | 5 + target/arm/helper.c | 3 +- target/arm/monitor.c | 2 +- target/i386/cpu.c | 7 +- target/i386/sev_i386.h | 2 +- target/ppc/translate_init.inc.c | 3 +- target/s390x/cpu_models.c | 9 +- tests/Makefile.include | 4 +- tests/test-qmp-event.c | 7 +- tests/test-qobject-input-visitor.c | 1 - ui/vnc.c | 3 +- 35 files changed, 623 insertions(+), 744 deletions(-) create mode 100644 qapi/target.json delete mode 100644 stubs/arch-query-cpu-def.c delete mode 100644 stubs/arch-query-cpu-model-baseline.c delete mode 100644 stubs/arch-query-cpu-model-comparison.c delete mode 100644 stubs/arch-query-cpu-model-expansion.c
Signature · 1 line
2.17.2
RFC PATCH v2 1/15 qapi: Belatedly update docs for commit 9c2f56e9f9d
--- docs/devel/qapi-code-gen.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
docs/devel/qapi-code-gen.txt +2 -2
@@ -1369,8 +1369,8 @@ Example: void qapi_event_send_my_event(void); typedef enum example_QAPIEvent { - EXAMPLE_QAPI_EVENT_MY_EVENT = 0, - EXAMPLE_QAPI_EVENT__MAX = 1, + EXAMPLE_QAPI_EVENT_MY_EVENT, + EXAMPLE_QAPI_EVENT__MAX, } example_QAPIEvent; #define example_QAPIEvent_str(val) \
Signature · 1 line
2.17.2
Re: [Qemu-devel] [RFC PATCH v2 01/15] qapi: Belatedly update docs for commit 9c2f56e9f9d
Quoted 2 lines · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>
Quoted 22 lines
--- docs/devel/qapi-code-gen.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)docs/devel/qapi-code-gen.txt +2
-3@@ -1369,8 +1369,8 @@ Example: void qapi_event_send_my_event(void); typedef enum example_QAPIEvent { - EXAMPLE_QAPI_EVENT_MY_EVENT = 0, - EXAMPLE_QAPI_EVENT__MAX = 1, + EXAMPLE_QAPI_EVENT_MY_EVENT, + EXAMPLE_QAPI_EVENT__MAX, } example_QAPIEvent; #define example_QAPIEvent_str(val) \ --2.17.2
RFC PATCH v2 2/15 qapi: Eliminate indirection through qmp_event_get_func_emit()
In reply to Markus ArmbrusterThe qapi_event_send_FOO() functions emit events like this:
QMPEventFuncEmit emit;
emit = qmp_event_get_func_emit();
if (!emit) {
return;
}
qmp = qmp_event_build_dict("FOO");
[put event arguments into @qmp...]
emit(QAPI_EVENT_FOO, qmp);The value of qmp_event_get_func_emit() depends only on the program:
* In qemu-system-FOO, it's always monitor_qapi_event_queue.
* In tests/test-qmp-event, it's always event_test_emit.
* In all other programs, it's always null.
This is exactly the kind of dependence the linker is supposed to resolve; we don't actually need an indirection.
Note that things would fall apart if we linked more than one QAPI schema into a single program: each set of qapi_event_send_FOO() uses its own event enumeration, yet they share a single emit function. Which takes the event enumeration as an argument. Which one if there's more than one?
More seriously: how does this work even now? qemu-system-FOO wants QAPIEvent, and passes a function taking that to qmp_event_set_func_emit(). test-qmp-event wants test_QAPIEvent, and passes a function taking that to qmp_event_set_func_emit().
I works by type trickery, of course:
typedef void (*QMPEventFuncEmit)(unsigned event, QDict *dict);
void qmp_event_set_func_emit(QMPEventFuncEmit emit);
QMPEventFuncEmit qmp_event_get_func_emit(void);We use unsigned instead of the enumeration type. Relies on both enumerations boiling down to unsigned, which happens to be true for the compilers we use.
Clean this up as follows:
* Generate qapi_event_send_FOO() that call PREFIX_qapi_event_emit() instead of the value of qmp_event_set_func_emit().
* Generate a prototype for PREFIX_qapi_event_emit() into qapi-events.h.
* PREFIX_ is empty for qapi/qapi-schema.json, and test_ for tests/qapi-schema/qapi-schema-test.json. It's qga_ for qga/qapi-schema.json, and doc-good- for tests/qapi-schema/doc-good-qapi-doc.texi, but those don't define any events.
* Rename monitor_qapi_event_queue() to qapi_event_emit() instead of passing it to qmp_event_set_func_emit(). This takes care of qemu-system-FOO.
* Rename event_test_emit() to test_qapi_event_emit() instead of passing it to qmp_event_set_func_emit(). This takes care of tests/test-qmp-event.
* Add a qapi_event_emit() that does nothing to stubs/monitor.c. This takes care of all other programs that link code emitting QMP events.
* Drop qmp_event_set_func_emit(), qmp_event_get_func_emit().
--- docs/devel/qapi-code-gen.txt | 8 +------- include/qapi/qmp-event.h | 6 ------ monitor.c | 4 +--- qapi/qmp-event.c | 12 ------------ scripts/qapi/events.py | 24 ++++++++++++++---------- stubs/monitor.c | 5 +++++ tests/Makefile.include | 4 ++-- tests/test-qmp-event.c | 6 +----- 8 files changed, 24 insertions(+), 45 deletions(-)
docs/devel/qapi-code-gen.txt +1 -7
@@ -1385,16 +1385,10 @@ Example: void qapi_event_send_my_event(void) { QDict *qmp; - QMPEventFuncEmit emit; - - emit = qmp_event_get_func_emit(); - if (!emit) { - return; - } qmp = qmp_event_build_dict("MY_EVENT"); - emit(EXAMPLE_QAPI_EVENT_MY_EVENT, qmp); + example_qapi_event_emit(EXAMPLE_QAPI_EVENT_MY_EVENT, qmp); qobject_unref(qmp); }
include/qapi/qmp-event.h +0 -6
@@ -14,11 +14,5 @@#ifndef QMP_EVENT_H #define QMP_EVENT_H -typedef void (*QMPEventFuncEmit )(unsigned event,QDict *dict); - -void qmp_event_set_func_emit (QMPEventFuncEmit emit); - -QMPEventFuncEmit qmp_event_get_func_emit (void ); -QDict *qmp_event_build_dict (const char *event_name);#endif
monitor.c +1 -3
@@ -590,8 +590,7 @@ monitor_qapi_event_queue_no_reenter(QAPIEvent event, QDict *qdict)qemu_mutex_unlock (&monitor_lock); } -static void -monitor_qapi_event_queue (QAPIEvent event,QDict *qdict) +void qapi_event_emit (QAPIEvent event,QDict *qdict) {/* * monitor_qapi_event_queue_no_reenter() is not reentrant: it
@@ -704,7 +703,6 @@ static void monitor_qapi_event_init(void) { monitor_qapi_event_state =g_hash_table_new (qapi_event_throttle_hash, qapi_event_throttle_equal); -qmp_event_set_func_emit (monitor_qapi_event_queue); }static void handle_hmp_command (Monitor *mon,const char *cmdline);
qapi/qmp-event.c +0 -12
@@ -19,18 +19,6 @@#include "qapi/qmp/qdict.h" #include "qapi/qmp/qjson.h" -static QMPEventFuncEmit qmp_emit; - -void qmp_event_set_func_emit (QMPEventFuncEmit emit) -{ - qmp_emit = emit; -} - -QMPEventFuncEmit qmp_event_get_func_emit (void ) -{ -return qmp_emit; -} -static void timestamp_put (QDict *qdict) {int err;
scripts/qapi/events.py +14 -10
@@ -58,7 +58,7 @@ def gen_param_var(typ): return ret -def gen_event_send(name, arg_type, boxed, event_enum_name): +def gen_event_send(name, arg_type, boxed, event_enum_name, event_emit): # FIXME: Our declaration of local variables (and of 'errp' in the # parameter list) can collide with exploded members of the event's # data type passed in as parameters. If this collision ever hits in
@@ -70,7 +70,6 @@ def gen_event_send(name, arg_type, boxed, event_enum_name): %(proto)s { QDict *qmp; - QMPEventFuncEmit emit; ''', proto=build_event_send_proto(name, arg_type, boxed))
@@ -86,11 +85,6 @@ def gen_event_send(name, arg_type, boxed, event_enum_name): ret += mcgen(''' - emit = qmp_event_get_func_emit(); - if (!emit) { - return; - } - qmp = qmp_event_build_dict("%(name)s"); ''',
@@ -121,9 +115,10 @@ def gen_event_send(name, arg_type, boxed, event_enum_name): ''') ret += mcgen(''' - emit(%(c_enum)s, qmp); + %(event_emit)s(%(c_enum)s, qmp); ''', + event_emit=event_emit, c_enum=c_enum_const(event_enum_name, name)) if arg_type and not arg_type.is_empty():
@@ -145,6 +140,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor): ' * Schema-defined QAPI/QMP events', __doc__) self._event_enum_name = c_name(prefix + 'QAPIEvent', protect=False) self._event_enum_members = [] + self._event_emit_name = c_name(prefix + 'qapi_event_emit') def _begin_module(self, name): types = self._module_basename('qapi-types', name)
@@ -170,15 +166,23 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor): def visit_end(self): (genc, genh) = self._module[self._main_module] - genh.add(gen_enum(self._event_enum_name, self._event_enum_members)) + genh.add(gen_enum(self._event_enum_name, + self._event_enum_members)) genc.add(gen_enum_lookup(self._event_enum_name, self._event_enum_members)) + genh.add(mcgen(''' + +void %(event_emit)s(%(event_enum)s event, QDict *qdict); +''', + event_emit=self._event_emit_name, + event_enum=self._event_enum_name)) def visit_event(self, name, info, ifcond, arg_type, boxed): with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_event_send_decl(name, arg_type, boxed)) self._genc.add(gen_event_send(name, arg_type, boxed, - self._event_enum_name)) + self._event_enum_name, + self._event_emit_name)) self._event_enum_members.append(QAPISchemaMember(name, ifcond))
stubs/monitor.c +5 -0
@@ -1,5 +1,6 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-events.h" #include "qemu-common.h" #include "monitor/monitor.h"
@@ -14,3 +15,7 @@ int monitor_get_fd(Monitor *mon, const char *name, Error **errp)void monitor_init (Chardev *chr,int flags) { } + +void qapi_event_emit (QAPIEvent event,QDict *qdict) +{ +}
tests/Makefile.include +2 -2
@@ -519,7 +519,7 @@ QEMU_CFLAGS += -I$(SRC_PATH)/tests test-util-obj-y = libqemuutil.a test-qom-obj-y = $(qom-obj-y) $(test-util-obj-y) test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o \ - tests/test-qapi-events.o tests/test-qapi-introspect.o \ + tests/test-qapi-introspect.o \ $(test-qom-obj-y) benchmark-crypto-obj-y = $(crypto-obj-y) $(test-qom-obj-y) test-crypto-obj-y = $(crypto-obj-y) $(test-qom-obj-y)
@@ -611,7 +611,7 @@ tests/qapi-schema/doc-good.test.texi: $(SRC_PATH)/tests/qapi-schema/doc-good.jso tests/test-string-output-visitor$(EXESUF): tests/test-string-output-visitor.o $(test-qapi-obj-y) tests/test-string-input-visitor$(EXESUF): tests/test-string-input-visitor.o $(test-qapi-obj-y) -tests/test-qmp-event$(EXESUF): tests/test-qmp-event.o $(test-qapi-obj-y) +tests/test-qmp-event$(EXESUF): tests/test-qmp-event.o $(test-qapi-obj-y) tests/test-qapi-events.o tests/test-qobject-output-visitor$(EXESUF): tests/test-qobject-output-visitor.o $(test-qapi-obj-y) tests/test-clone-visitor$(EXESUF): tests/test-clone-visitor.o $(test-qapi-obj-y) tests/test-qobject-input-visitor$(EXESUF): tests/test-qobject-input-visitor.o $(test-qapi-obj-y)
tests/test-qmp-event.c +1 -5
@@ -93,9 +93,7 @@ static bool qdict_cmp_simple(QDict *a, QDict *b)return d.result; } -/* This function is hooked as final emit function, which can verify the -correctness. */ -static void event_test_emit (test_QAPIEvent event,QDict *d) +void test_qapi_event_emit (test_QAPIEvent event,QDict *d) {QDict *t;int64_t s, ms;
@@ -241,8 +239,6 @@ static void test_event_d(TestEventData *data,int main (int argc,char **argv) { -qmp_event_set_func_emit (event_test_emit); -g_test_init (&argc, &argv,NULL );event_test_add ("/event/event_a" , test_event_a);
Signature · 1 line
2.17.2
Re: [Qemu-devel] [RFC PATCH v2 02/15] qapi: Eliminate indirection through qmp_event_get_func_emit()
Quoted 71 lines · Markus Armbruster
The
qapi_event_send_FOO()functions emit events like this:QMPEventFuncEmit emit; emit = qmp_event_get_func_emit(); if (!emit) { return; } qmp = qmp_event_build_dict("FOO"); [put event arguments into @qmp...] emit(QAPI_EVENT_FOO, qmp);The value of
qmp_event_get_func_emit()depends only on the program:* In qemu-system-FOO, it's always
monitor_qapi_event_queue.* In tests/test-qmp-event, it's always
event_test_emit.* In all other programs, it's always null.
This is exactly the kind of dependence the linker is supposed to resolve; we don't actually need an indirection.
Note that things would fall apart if we linked more than one QAPI schema into a single program: each set of
qapi_event_send_FOO()uses its own event enumeration, yet they share a single emit function. Which takes the event enumeration as an argument. Which one if there's more than one?More seriously: how does this work even now? qemu-system-FOO wants QAPIEvent, and passes a function taking that to
qmp_event_set_func_emit(). test-qmp-event wantstest_QAPIEvent, and passes a function taking that toqmp_event_set_func_emit().I works by type trickery, of course:
typedef void (*QMPEventFuncEmit)(unsigned event, QDict *dict); void qmp_event_set_func_emit(QMPEventFuncEmit emit); QMPEventFuncEmit qmp_event_get_func_emit(void);We use unsigned instead of the enumeration type. Relies on both enumerations boiling down to unsigned, which happens to be true for the compilers we use.
Clean this up as follows:
* Generate
qapi_event_send_FOO()that callPREFIX_qapi_event_emit()instead of the value ofqmp_event_set_func_emit().* Generate a prototype for
PREFIX_qapi_event_emit()intoqapi-events.h.*
PREFIX_is empty forqapi/qapi-schema.json, andtest_fortests/qapi-schema/qapi-schema-test.json. It'sqga_forqga/qapi-schema.json, and doc-good- for tests/qapi-schema/doc-good-qapi-doc.texi, but those don't define any events.* Rename
monitor_qapi_event_queue()toqapi_event_emit()instead of passing it toqmp_event_set_func_emit(). This takes care of qemu-system-FOO.* Rename
event_test_emit()totest_qapi_event_emit()instead of passing it toqmp_event_set_func_emit(). This takes care of tests/test-qmp-event.
Quoted 6 lines
* Add a
qapi_event_emit()that does nothing tostubs/monitor.c. This takes care of all other programs that link code emitting QMP events.* Drop
qmp_event_set_func_emit(),qmp_event_get_func_emit().Signed-off-by Markus Armbruster <[email protected]>
Quoted 242 lines
--- docs/devel/qapi-code-gen.txt | 8 +------- include/qapi/qmp-event.h | 6 ------ monitor.c | 4 +--- qapi/qmp-event.c | 12 ------------ scripts/qapi/events.py | 24 ++++++++++++++---------- stubs/monitor.c | 5 +++++ tests/Makefile.include | 4 ++-- tests/test-qmp-event.c | 6 +----- 8 files changed, 24 insertions(+), 45 deletions(-)docs/devel/qapi-code-gen.txt +1
-7@@ -1385,16 +1385,10 @@ Example: void qapi_event_send_my_event(void) { QDict *qmp; - QMPEventFuncEmit emit; - - emit = qmp_event_get_func_emit(); - if (!emit) { - return; - } qmp = qmp_event_build_dict("MY_EVENT"); - emit(EXAMPLE_QAPI_EVENT_MY_EVENT, qmp); + example_qapi_event_emit(EXAMPLE_QAPI_EVENT_MY_EVENT, qmp); qobject_unref(qmp); }include/qapi/qmp-event.h +0
-6@@ -14,11 +14,5 @@#ifndef QMP_EVENT_H #define QMP_EVENT_H -typedef void (*QMPEventFuncEmit )(unsigned event,QDict *dict); - -void qmp_event_set_func_emit (QMPEventFuncEmit emit); - -QMPEventFuncEmit qmp_event_get_func_emit (void ); -QDict *qmp_event_build_dict (const char *event_name);#endif monitor.c +1
-3@@ -590,8 +590,7 @@ monitor_qapi_event_queue_no_reenter(QAPIEvent event, QDict *qdict)qemu_mutex_unlock (&monitor_lock); } -static void -monitor_qapi_event_queue (QAPIEvent event,QDict *qdict) +void qapi_event_emit (QAPIEvent event,QDict *qdict) {/* * monitor_qapi_event_queue_no_reenter() is not reentrant: it @@ -704,7 +703,6 @@ static void monitor_qapi_event_init(void) { monitor_qapi_event_state =g_hash_table_new (qapi_event_throttle_hash, qapi_event_throttle_equal); -qmp_event_set_func_emit (monitor_qapi_event_queue); }static void handle_hmp_command (Monitor *mon,const char *cmdline);qapi/qmp-event.c +0
-12@@ -19,18 +19,6 @@#include "qapi/qmp/qdict.h" #include "qapi/qmp/qjson.h" -static QMPEventFuncEmit qmp_emit; - -void qmp_event_set_func_emit (QMPEventFuncEmit emit) -{ - qmp_emit = emit; -} - -QMPEventFuncEmit qmp_event_get_func_emit (void ) -{ -return qmp_emit; -} -static void timestamp_put (QDict *qdict) {int err;scripts/qapi/events.py +14
-10@@ -58,7 +58,7 @@ def gen_param_var(typ): return ret -def gen_event_send(name, arg_type, boxed, event_enum_name): +def gen_event_send(name, arg_type, boxed, event_enum_name, event_emit): # FIXME: Our declaration of local variables (and of 'errp' in the # parameter list) can collide with exploded members of the event's # data type passed in as parameters. If this collision ever hits in@@ -70,7 +70,6 @@ def gen_event_send(name, arg_type, boxed, event_enum_name): %(proto)s { QDict *qmp; - QMPEventFuncEmit emit; ''', proto=build_event_send_proto(name, arg_type, boxed))@@ -86,11 +85,6 @@ def gen_event_send(name, arg_type, boxed, event_enum_name): ret += mcgen(''' - emit = qmp_event_get_func_emit(); - if (!emit) { - return; - } - qmp = qmp_event_build_dict("%(name)s"); ''',@@ -121,9 +115,10 @@ def gen_event_send(name, arg_type, boxed, event_enum_name): ''') ret += mcgen(''' - emit(%(c_enum)s, qmp); + %(event_emit)s(%(c_enum)s, qmp); ''', + event_emit=event_emit, c_enum=c_enum_const(event_enum_name, name)) if arg_type and not arg_type.is_empty():@@ -145,6 +140,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor): ' * Schema-defined QAPI/QMP events', __doc__) self._event_enum_name = c_name(prefix + 'QAPIEvent', protect=False) self._event_enum_members = [] + self._event_emit_name = c_name(prefix + 'qapi_event_emit') def _begin_module(self, name): types = self._module_basename('qapi-types', name)@@ -170,15 +166,23 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor): def visit_end(self): (genc, genh) = self._module[self._main_module] - genh.add(gen_enum(self._event_enum_name, self._event_enum_members)) + genh.add(gen_enum(self._event_enum_name, + self._event_enum_members)) genc.add(gen_enum_lookup(self._event_enum_name, self._event_enum_members)) + genh.add(mcgen(''' + +void %(event_emit)s(%(event_enum)s event, QDict *qdict); +''', + event_emit=self._event_emit_name, + event_enum=self._event_enum_name)) def visit_event(self, name, info, ifcond, arg_type, boxed): with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_event_send_decl(name, arg_type, boxed)) self._genc.add(gen_event_send(name, arg_type, boxed, - self._event_enum_name)) + self._event_enum_name, + self._event_emit_name)) self._event_enum_members.append(QAPISchemaMember(name, ifcond))stubs/monitor.c +5
-0@@ -1,5 +1,6 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-events.h" #include "qemu-common.h" #include "monitor/monitor.h" @@ -14,3 +15,7 @@ int monitor_get_fd(Monitor *mon, const char *name, Error **errp)void monitor_init (Chardev *chr,int flags) { } + +void qapi_event_emit (QAPIEvent event,QDict *qdict) +{ +}tests/Makefile.include +2
-2@@ -519,7 +519,7 @@ QEMU_CFLAGS += -I$(SRC_PATH)/tests test-util-obj-y = libqemuutil.a test-qom-obj-y = $(qom-obj-y) $(test-util-obj-y) test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o \ - tests/test-qapi-events.o tests/test-qapi-introspect.o \ + tests/test-qapi-introspect.o \ $(test-qom-obj-y) benchmark-crypto-obj-y = $(crypto-obj-y) $(test-qom-obj-y) test-crypto-obj-y = $(crypto-obj-y) $(test-qom-obj-y)@@ -611,7 +611,7 @@ tests/qapi-schema/doc-good.test.texi: $(SRC_PATH)/tests/qapi-schema/doc-good.jso tests/test-string-output-visitor$(EXESUF): tests/test-string-output-visitor.o $(test-qapi-obj-y) tests/test-string-input-visitor$(EXESUF): tests/test-string-input-visitor.o $(test-qapi-obj-y) -tests/test-qmp-event$(EXESUF): tests/test-qmp-event.o $(test-qapi-obj-y) +tests/test-qmp-event$(EXESUF): tests/test-qmp-event.o $(test-qapi-obj-y) tests/test-qapi-events.o tests/test-qobject-output-visitor$(EXESUF): tests/test-qobject-output-visitor.o $(test-qapi-obj-y) tests/test-clone-visitor$(EXESUF): tests/test-clone-visitor.o $(test-qapi-obj-y) tests/test-qobject-input-visitor$(EXESUF): tests/test-qobject-input-visitor.o $(test-qapi-obj-y)tests/test-qmp-event.c +1
-6@@ -93,9 +93,7 @@ static bool qdict_cmp_simple(QDict *a, QDict *b)return d.result; } -/* This function is hooked as final emit function, which can verify the -correctness. */ -static void event_test_emit (test_QAPIEvent event,QDict *d) +void test_qapi_event_emit (test_QAPIEvent event,QDict *d) {QDict *t;int64_t s, ms;@@ -241,8 +239,6 @@ static void test_event_d(TestEventData *data,int main (int argc,char **argv) { -qmp_event_set_func_emit (event_test_emit); -g_test_init (&argc, &argv,NULL );event_test_add ("/event/event_a" , test_event_a); --2.17.2
Signature · 1 line
Marc-André Lureau
Re: [Qemu-devel] [RFC PATCH v2 02/15] qapi: Eliminate indirection through qmp_event_get_func_emit()
In reply to Markus ArmbrusterQuoted 13 lines · Markus Armbruster
The
qapi_event_send_FOO()functions emit events like this:QMPEventFuncEmit emit; emit = qmp_event_get_func_emit(); if (!emit) { return; } emit(QAPI_EVENT_FOO, qmp);
Quoted 6 lines
More seriously: how does this work even now? qemu-system-FOO wants QAPIEvent, and passes a function taking that to
qmp_event_set_func_emit(). test-qmp-event wantstest_QAPIEvent, and passes a function taking that toqmp_event_set_func_emit().I works by type trickery, of course:
s/I/It/
Quoted 16 lines
typedef void (*QMPEventFuncEmit)(unsigned event, QDict *dict); void qmp_event_set_func_emit(QMPEventFuncEmit emit); QMPEventFuncEmit qmp_event_get_func_emit(void);We use unsigned instead of the enumeration type. Relies on both enumerations boiling down to unsigned, which happens to be true for the compilers we use.
Clean this up as follows:
* Generate
qapi_event_send_FOO()that callPREFIX_qapi_event_emit()instead of the value ofqmp_event_set_func_emit().
Quoted 8 lines
* Generate a prototype for
PREFIX_qapi_event_emit()intoqapi-events.h.*
PREFIX_is empty forqapi/qapi-schema.json, andtest_fortests/qapi-schema/qapi-schema-test.json. It'sqga_forqga/qapi-schema.json, and doc-good- for tests/qapi-schema/doc-good-qapi-doc.texi, but those don't define any events.
Wait - PREFIX is qga_ or doc_good_...
Quoted 2 lines
* Add a
qapi_event_emit()that does nothing tostubs/monitor.c. This takes care of all other programs that link code emitting QMP events.
...but the stub function is defined without a prefix?
Quoted 16 lines
+++
b/stubs/monitor.cstubs/monitor.c +5
-0@@ -1,5 +1,6 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-events.h" #include "qemu-common.h" #include "monitor/monitor.h" @@ -14,3 +15,7 @@ int monitor_get_fd(Monitor *mon, const char *name, Error **errp)void monitor_init (Chardev *chr,int flags) { } + +void qapi_event_emit (QAPIEvent event,QDict *qdict) +{ +}
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [RFC PATCH v2 02/15] qapi: Eliminate indirection through qmp_event_get_func_emit()
Quoted 14 lines · Eric Blake
Quoted 12 lines · Markus Armbruster
The
qapi_event_send_FOO()functions emit events like this:QMPEventFuncEmit emit; emit = qmp_event_get_func_emit(); if (!emit) { return; } emit(QAPI_EVENT_FOO, qmp);
Quoted 8 lines
Quoted 6 lines
More seriously: how does this work even now? qemu-system-FOO wants QAPIEvent, and passes a function taking that to
qmp_event_set_func_emit(). test-qmp-event wantstest_QAPIEvent, and passes a function taking that toqmp_event_set_func_emit().I works by type trickery, of course:
s/I/It/
Of course.
Quoted 19 lines
Quoted 19 lines
typedef void (*QMPEventFuncEmit)(unsigned event, QDict *dict); void qmp_event_set_func_emit(QMPEventFuncEmit emit); QMPEventFuncEmit qmp_event_get_func_emit(void);We use unsigned instead of the enumeration type. Relies on both enumerations boiling down to unsigned, which happens to be true for the compilers we use.
Clean this up as follows:
* Generate
qapi_event_send_FOO()that callPREFIX_qapi_event_emit()instead of the value ofqmp_event_set_func_emit().* Generate a prototype for
PREFIX_qapi_event_emit()intoqapi-events.h.
Quoted 7 lines
Quoted 5 lines
*
PREFIX_is empty forqapi/qapi-schema.json, andtest_fortests/qapi-schema/qapi-schema-test.json. It'sqga_forqga/qapi-schema.json, and doc-good- for tests/qapi-schema/doc-good-qapi-doc.texi, but those don't define any events.Wait - PREFIX is
qga_ordoc_good_...
Yes.
Quoted 4 lines
Quoted 2 lines
* Add a
qapi_event_emit()that does nothing tostubs/monitor.c. This takes care of all other programs that link code emitting QMP events....but the stub function is defined without a prefix?
It's defined with a prefix, except in the commit message ;) Will fix, thanks!
Re: [Qemu-devel] [RFC PATCH v2 02/15] qapi: Eliminate indirection through qmp_event_get_func_emit()
Quoted 21 lines · Markus Armbruster
Quoted 19 lines · Eric Blake
Quoted 18 lines · Markus Armbruster
The
qapi_event_send_FOO()functions emit events like this:QMPEventFuncEmit emit; emit = qmp_event_get_func_emit(); if (!emit) { return; } emit(QAPI_EVENT_FOO, qmp);More seriously: how does this work even now? qemu-system-FOO wants QAPIEvent, and passes a function taking that to
qmp_event_set_func_emit(). test-qmp-event wantstest_QAPIEvent, and passes a function taking that toqmp_event_set_func_emit().
Quoted 30 lines
Quoted 3 lines
Quoted 1 line
I works by type trickery, of course:
s/I/It/
Of course.
Quoted 24 lines
Quoted 24 lines
typedef void (*QMPEventFuncEmit)(unsigned event, QDict *dict); void qmp_event_set_func_emit(QMPEventFuncEmit emit); QMPEventFuncEmit qmp_event_get_func_emit(void);We use unsigned instead of the enumeration type. Relies on both enumerations boiling down to unsigned, which happens to be true for the compilers we use.
Clean this up as follows:
* Generate
qapi_event_send_FOO()that callPREFIX_qapi_event_emit()instead of the value ofqmp_event_set_func_emit().* Generate a prototype for
PREFIX_qapi_event_emit()intoqapi-events.h.*
PREFIX_is empty forqapi/qapi-schema.json, andtest_fortests/qapi-schema/qapi-schema-test.json. It'sqga_forqga/qapi-schema.json, and doc-good- for tests/qapi-schema/doc-good-qapi-doc.texi, but those don't define any events.
Make that doc-good.json.
Quoted 5 lines
Quoted 2 lines
Wait - PREFIX is
qga_ordoc_good_...Yes.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
* Add a
qapi_event_emit()that does nothing tostubs/monitor.c. This takes care of all other programs that link code emitting QMP events....but the stub function is defined without a prefix?
It's defined with a prefix, except in the commit message ;) Will fix, thanks!
Nonsense.
Since PREFIX_ is empty for qapi/qapi-schema.json, the generated qapi_event_send_EVENT for the EVENT defined there all call qapi_event_emit().
The stub makes qapi_event_send_EVENT() work for any EVENT defined there in programs that don't link (non-stub) monitor.c.
PREFIX is non-empty for the other two, but no events are defined there. qga_qapi_event_emit() and doc_good_qapi_event_emit() are neither used nor defined anywhere.
Clear now?
RFC PATCH v2 3/15 qapi: Generate QAPIEvent stuff into separate files WIP
In reply to Markus ArmbrusterHaving to include qapi-events.h just for QAPIEvent is suboptimal, but quite tolerable. It'll become problematic when we have events conditional on the target, because then qapi-events.h won't be usable from target-independent code anymore. Avoid that by generating it into separate files.
This is work-in-progress because I conjure up a module to generate separate files. Not nice, since that module's name can clash with a user module's name. Pick module name 'FIXME' to make abundantly clear this is a bad idea.
TODO Update docs/devel/qapi-code-gen.txt.
--- Makefile | 1 + Makefile.objs | 1 + monitor.c | 2 +- scripts/qapi/events.py | 33 ++++++++++++++++++++++----------- stubs/monitor.c | 2 +- tests/test-qmp-event.c | 1 + ui/vnc.c | 3 ++- 7 files changed, 29 insertions(+), 14 deletions(-)
Makefile +1 -0
@@ -101,6 +101,7 @@ GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.c) GENERATED_QAPI_FILES += qapi/qapi-commands.h qapi/qapi-commands.c GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.h) GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.c) +GENERATED_QAPI_FILES += qapi/qapi-events-FIXME.h qapi/qapi-events-FIXME.c GENERATED_QAPI_FILES += qapi/qapi-events.h qapi/qapi-events.c GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.h) GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.c)
Makefile.objs +1 -0
@@ -11,6 +11,7 @@ util-obj-y += $(QAPI_MODULES:%=qapi/qapi-types-%.o) util-obj-y += qapi/qapi-builtin-visit.o util-obj-y += qapi/qapi-visit.o util-obj-y += $(QAPI_MODULES:%=qapi/qapi-visit-%.o) +util-obj-y += qapi/qapi-events-FIXME.o util-obj-y += qapi/qapi-events.o util-obj-y += $(QAPI_MODULES:%=qapi/qapi-events-%.o) util-obj-y += qapi/qapi-introspect.o
monitor.c +1 -1
@@ -75,7 +75,7 @@#include "qemu/thread.h" #include "block/qapi.h" #include "qapi/qapi-commands.h" -#include "qapi/qapi-events.h" +#include "qapi/qapi-events-FIXME.h" #include "qapi/error.h" #include "qapi/qmp-event.h" #include "qapi/qapi-introspect.h"
scripts/qapi/events.py +22 -11
@@ -143,12 +143,14 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor): self._event_emit_name = c_name(prefix + 'qapi_event_emit') def _begin_module(self, name): + events = self._module_basename('qapi-events', name) types = self._module_basename('qapi-types', name) visit = self._module_basename('qapi-visit', name) self._genc.add(mcgen(''' #include "qemu/osdep.h" #include "qemu-common.h" -#include "%(prefix)sqapi-events.h" +#include "%(prefix)sqapi-events-FIXME.h" +#include "%(events)s.h" #include "%(visit)s.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h"
@@ -156,7 +158,8 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor): #include "qapi/qmp-event.h" ''', - visit=visit, prefix=self._prefix)) + events=events, visit=visit, + prefix=self._prefix)) self._genh.add(mcgen(''' #include "qapi/util.h" #include "%(types)s.h"
@@ -165,17 +168,25 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor): types=types)) def visit_end(self): - (genc, genh) = self._module[self._main_module] - genh.add(gen_enum(self._event_enum_name, - self._event_enum_members)) - genc.add(gen_enum_lookup(self._event_enum_name, - self._event_enum_members)) - genh.add(mcgen(''' + self._add_module('FIXME', ' * QAPI Events FIXME') + self._genc.preamble_add(mcgen(''' +#include "qemu/osdep.h" +#include "%(prefix)sqapi-events-FIXME.h" +''', + prefix=self._prefix)) + self._genh.preamble_add(mcgen(''' +#include "qapi/util.h" +''')) + self._genh.add(gen_enum(self._event_enum_name, + self._event_enum_members)) + self._genc.add(gen_enum_lookup(self._event_enum_name, + self._event_enum_members)) + self._genh.add(mcgen(''' void %(event_emit)s(%(event_enum)s event, QDict *qdict); ''', - event_emit=self._event_emit_name, - event_enum=self._event_enum_name)) + event_emit=self._event_emit_name, + event_enum=self._event_enum_name)) def visit_event(self, name, info, ifcond, arg_type, boxed): with ifcontext(ifcond, self._genh, self._genc):
@@ -189,4 +200,4 @@ void %(event_emit)s(%(event_enum)s event, QDict *qdict); def gen_events(schema, output_dir, prefix): vis = QAPISchemaGenEventVisitor(prefix) schema.visit(vis) - vis.write(output_dir) + vis.write(output_dir, True)
stubs/monitor.c +1 -1
@@ -1,6 +1,6 @@#include "qemu/osdep.h" #include "qapi/error.h" -#include "qapi/qapi-events.h" +#include "qapi/qapi-events-FIXME.h" #include "qemu-common.h" #include "monitor/monitor.h"
tests/test-qmp-event.c +1 -0
@@ -21,6 +21,7 @@#include "qapi/qmp/qstring.h" #include "qapi/qmp-event.h" #include "test-qapi-events.h" +#include "test-qapi-events-FIXME.h" typedef struct TestEventData { QDict *expect;
ui/vnc.c +2 -1
@@ -35,7 +35,8 @@#include "qemu/timer.h" #include "qemu/acl.h" #include "qemu/config-file.h" -#include "qapi/qapi-events.h" +#include "qapi/qapi-events-FIXME.h" +#include "qapi/qapi-events-ui.h" #include "qapi/error.h" #include "qapi/qapi-commands-ui.h" #include "ui/input.h"
Signature · 1 line
2.17.2
RFC PATCH v2 4/15 build-sys: move qmp-introspect per target
In reply to Markus ArmbrusterFrom: Marc-André Lureau <[email protected]>
The following patches are going to introduce per-target #ifdef in the schemas.
The introspection data is statically generated once, and must thus be built per-target to reflect target-specific configuration.
Drop "do_test_visitor_in_qmp_introspect(&qmp_schema_qlit)" since the schema is no longer in a common object. It is covered by the per-target query-qmp-schema test instead.
--- Makefile.objs | 2 -- Makefile.target | 2 ++ tests/test-qobject-input-visitor.c | 1 - 3 files changed, 2 insertions(+), 3 deletions(-)
Makefile.objs +0 -2
@@ -14,7 +14,6 @@ util-obj-y += $(QAPI_MODULES:%=qapi/qapi-visit-%.o) util-obj-y += qapi/qapi-events-FIXME.o util-obj-y += qapi/qapi-events.o util-obj-y += $(QAPI_MODULES:%=qapi/qapi-events-%.o) -util-obj-y += qapi/qapi-introspect.o chardev-obj-y = chardev/
@@ -95,7 +94,6 @@ common-obj-$(CONFIG_FDT) += device_tree.o common-obj-y += qapi/qapi-commands.o common-obj-y += $(QAPI_MODULES:%=qapi/qapi-commands-%.o) -common-obj-y += qapi/qapi-introspect.o common-obj-y += qmp.o hmp.o endif
Makefile.target +2 -0
@@ -156,6 +156,8 @@ endif GENERATED_FILES += hmp-commands.h hmp-commands-info.h +obj-y += qapi/qapi-introspect.o + endif # CONFIG_SOFTMMU dummy := $(call unnest-vars,,obj-y)
tests/test-qobject-input-visitor.c +0 -1
@@ -1271,7 +1271,6 @@ static void test_visitor_in_qmp_introspect(TestInputVisitorData *data, const void *unused) {do_test_visitor_in_qmp_introspect (data, &test_qmp_schema_qlit); -do_test_visitor_in_qmp_introspect (data, &qmp_schema_qlit); }int main (int argc,char **argv)
Signature · 1 line
2.17.2
RFC PATCH v2 5/15 qapi: New module target.json
In reply to Markus ArmbrusterWe can't add appropriate target-specific conditionals to misc.json, because that would make all of misc.json unusable in target-independent code. To keep misc.json target-independent, we need to split off target-dependent target.json.
This commit doesn't actually split off anything, it merely creates the empty module. The next few patches will move stuff from misc.json there.
--- Makefile.objs | 19 +++++++++---------- Makefile.target | 10 ++++++++++ qapi/qapi-schema.json | 1 + qapi/target.json | 13 +++++++++++++ 4 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 qapi/target.json
Makefile.objs +9 -10
@@ -1,19 +1,19 @@ -QAPI_MODULES = block-core block char common crypto introspect job migration -QAPI_MODULES += misc net rocker run-state sockets tpm trace transaction ui +QAPI_COMMON_MODULES = block-core block char common crypto introspect +QAPI_COMMON_MODULES += job migration misc net rocker run-state sockets +QAPI_COMMON_MODULES += tpm trace transaction ui +QAPI_TARGET_MODULES = target +QAPI_MODULES = $(QAPI_COMMON_MODULES) $(QAPI_TARGET_MODULES) ####################################################################### # Common libraries for tools and emulators stub-obj-y = stubs/ crypto/ util-obj-y = util/ qobject/ qapi/ util-obj-y += qapi/qapi-builtin-types.o -util-obj-y += qapi/qapi-types.o -util-obj-y += $(QAPI_MODULES:%=qapi/qapi-types-%.o) +util-obj-y += $(QAPI_COMMON_MODULES:%=qapi/qapi-types-%.o) util-obj-y += qapi/qapi-builtin-visit.o -util-obj-y += qapi/qapi-visit.o -util-obj-y += $(QAPI_MODULES:%=qapi/qapi-visit-%.o) +util-obj-y += $(QAPI_COMMON_MODULES:%=qapi/qapi-visit-%.o) util-obj-y += qapi/qapi-events-FIXME.o -util-obj-y += qapi/qapi-events.o -util-obj-y += $(QAPI_MODULES:%=qapi/qapi-events-%.o) +util-obj-y += $(QAPI_COMMON_MODULES:%=qapi/qapi-events-%.o) chardev-obj-y = chardev/
@@ -92,8 +92,7 @@ common-obj-$(CONFIG_FDT) += device_tree.o ###################################################################### # qapi -common-obj-y += qapi/qapi-commands.o -common-obj-y += $(QAPI_MODULES:%=qapi/qapi-commands-%.o) +common-obj-y += $(QAPI_COMMON_MODULES:%=qapi/qapi-commands-%.o) common-obj-y += qmp.o hmp.o endif
Makefile.target +10 -0
@@ -156,6 +156,16 @@ endif GENERATED_FILES += hmp-commands.h hmp-commands-info.h +# FIXME duplicates Makefile.obj's +QAPI_TARGET_MODULES = target +obj-y += $(QAPI_TARGET_MODULES:%=qapi/qapi-types-%.o) +obj-y += qapi/qapi-types.o +obj-y += $(QAPI_TARGET_MODULES:%=qapi/qapi-visit-%.o) +obj-y += qapi/qapi-visit.o +obj-y += $(QAPI_TARGET_MODULES:%=qapi/qapi-events-%.o) +obj-y += qapi/qapi-events.o +obj-y += $(QAPI_TARGET_MODULES:%=qapi/qapi-commands-%.o) +obj-y += qapi/qapi-commands.o obj-y += qapi/qapi-introspect.o endif # CONFIG_SOFTMMU
qapi/qapi-schema.json +1 -0
@@ -94,3 +94,4 @@ { 'include': 'trace.json' } { 'include': 'introspect.json' } { 'include': 'misc.json' } +{ 'include': 'target.json' }
qapi/target.json new file +13 -0
@@ -0,0 +1,13 @@ +# -*- Mode: Python -*- +# + +## +# = Target-specific commands & events +## + +## +# @TARGET-TEMPORARY-DUMMY: +# Will go away in the next commit. Needed in this one because empty +# modules don't generate anything, defeating this commit's purpose. +## +{ 'event': 'TARGET-TEMPORARY-DUMMY' }
Signature · 1 line
2.17.2
RFC PATCH v2 6/15 qapi: make rtc-reset-reinjection and SEV depend on TARGET_I386
In reply to Markus ArmbrusterFrom: Marc-André Lureau <[email protected]>
Move rtc-reset-reinjection and SEV in target.json and make them conditional on TARGET_I386.
--- hw/timer/mc146818rtc.c | 2 +- monitor.c | 31 -------- qapi/misc.json | 166 -------------------------------------- qapi/target.json | 177 ++++++++++++++++++++++++++++++++++++++++- target/i386/sev_i386.h | 2 +- 5 files changed, 175 insertions(+), 203 deletions(-)
hw/timer/mc146818rtc.c +1 -1
@@ -31,7 +31,7 @@#include "sysemu/replay.h" #include "hw/timer/mc146818rtc.h" #include "qapi/error.h" -#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-target.h" #include "qapi/qapi-events-misc.h" #include "qapi/visitor.h" #include "exec/address-spaces.h"
monitor.c +0 -31
@@ -1145,12 +1145,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data,*/ static void qmp_unregister_commands_hack (void ) { -#ifndef TARGET_I386 -qmp_unregister_command (&qmp_commands,"rtc-reset-reinjection" ); -qmp_unregister_command (&qmp_commands,"query-sev" ); -qmp_unregister_command (&qmp_commands,"query-sev-launch-measure" ); -qmp_unregister_command (&qmp_commands,"query-sev-capabilities" ); -#endif #ifndef TARGET_S390X qmp_unregister_command (&qmp_commands,"dump-skeys" );#endif
@@ -4671,31 +4665,6 @@ QemuOptsList qemu_mon_opts = { }, }; -#ifndef TARGET_I386 -void qmp_rtc_reset_reinjection (Error **errp) -{ -error_setg (errp,QERR_FEATURE_DISABLED ,"rtc-reset-reinjection" ); -} - -SevInfo *qmp_query_sev (Error **errp) -{ -error_setg (errp,QERR_FEATURE_DISABLED ,"query-sev" ); -return NULL ; -} - -SevLaunchMeasureInfo *qmp_query_sev_launch_measure (Error **errp) -{ -error_setg (errp,QERR_FEATURE_DISABLED ,"query-sev-launch-measure" ); -return NULL ; -} - -SevCapability *qmp_query_sev_capabilities (Error **errp) -{ -error_setg (errp,QERR_FEATURE_DISABLED ,"query-sev-capabilities" ); -return NULL ; -} -#endif -#ifndef TARGET_S390X void qmp_dump_skeys (const char *filename,Error **errp) {
qapi/misc.json +0 -166
178 lines not on this page · raw message
qapi/target.json +173 -4
181 lines not on this page · raw message
target/i386/sev_i386.h +1 -1
@@ -19,7 +19,7 @@#include "sysemu/kvm.h" #include "sysemu/sev.h" #include "qemu/error-report.h" -#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-target.h" #define SEV_POLICY_NODBG 0x1#define SEV_POLICY_NOKS 0x2
Signature · 1 line
2.17.2
RFC PATCH v2 7/15 qapi: make s390 commands depend on TARGET_S390X
In reply to Markus ArmbrusterFrom: Marc-André Lureau <[email protected]>
--- hw/s390x/s390-skeys.c | 2 +- include/sysemu/arch_init.h | 7 -- monitor.c | 14 --- qapi/misc.json | 137 ----------------------- qapi/target.json | 142 ++++++++++++++++++++++++ qmp.c | 14 --- stubs/Makefile.objs | 2 - stubs/arch-query-cpu-model-baseline.c | 13 --- stubs/arch-query-cpu-model-comparison.c | 13 --- target/s390x/cpu_models.c | 5 +- 10 files changed, 146 insertions(+), 203 deletions(-) delete mode 100644 stubs/arch-query-cpu-model-baseline.c delete mode 100644 stubs/arch-query-cpu-model-comparison.c
hw/s390x/s390-skeys.c +1 -1
@@ -14,7 +14,7 @@#include "hw/boards.h" #include "hw/s390x/storage-keys.h" #include "qapi/error.h" -#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-target.h" #include "qapi/qmp/qdict.h" #include "qemu/error-report.h" #include "sysemu/kvm.h"
include/sysemu/arch_init.h +0 -7
@@ -36,11 +36,4 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp);CpuModelExpansionInfo *arch_query_cpu_model_expansion (CpuModelExpansionType type,CpuModelInfo *mode,Error **errp); -CpuModelCompareInfo *arch_query_cpu_model_comparison (CpuModelInfo *modela, -CpuModelInfo *modelb, -Error **errp); -CpuModelBaselineInfo *arch_query_cpu_model_baseline (CpuModelInfo *modela, -CpuModelInfo *modelb, -Error **errp); -#endif
monitor.c +0 -14
@@ -1145,19 +1145,12 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data,*/ static void qmp_unregister_commands_hack (void ) { -#ifndef TARGET_S390X -qmp_unregister_command (&qmp_commands,"dump-skeys" ); -#endif #ifndef TARGET_ARM qmp_unregister_command (&qmp_commands,"query-gic-capabilities" );#endif #if !defined(TARGET_S390X ) && !defined(TARGET_I386 )qmp_unregister_command (&qmp_commands,"query-cpu-model-expansion" );#endif -#if !defined(TARGET_S390X ) -qmp_unregister_command (&qmp_commands,"query-cpu-model-baseline" ); -qmp_unregister_command (&qmp_commands,"query-cpu-model-comparison" ); -#endif #if !defined(TARGET_PPC ) && !defined(TARGET_ARM ) && !defined(TARGET_I386 ) \ && !defined(TARGET_S390X )qmp_unregister_command (&qmp_commands,"query-cpu-definitions" );
@@ -4665,13 +4658,6 @@ QemuOptsList qemu_mon_opts = { }, }; -#ifndef TARGET_S390X -void qmp_dump_skeys (const char *filename,Error **errp) -{ -error_setg (errp,QERR_FEATURE_DISABLED ,"dump-skeys" ); -} -#endif -#ifndef TARGET_ARM GICCapabilityList *qmp_query_gic_capabilities (Error **errp) {
qapi/misc.json +0 -137
149 lines not on this page · raw message
qapi/target.json +142 -0
151 lines not on this page · raw message
qmp.c +0 -14
@@ -617,20 +617,6 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,return arch_query_cpu_model_expansion (type, model, errp); } -CpuModelCompareInfo *qmp_query_cpu_model_comparison (CpuModelInfo *modela, -CpuModelInfo *modelb, -Error **errp) -{ -return arch_query_cpu_model_comparison (modela, modelb, errp); -} - -CpuModelBaselineInfo *qmp_query_cpu_model_baseline (CpuModelInfo *modela, -CpuModelInfo *modelb, -Error **errp) -{ -return arch_query_cpu_model_baseline (modela, modelb, errp); -} -void qmp_add_client (const char *protocol,const char *fdname,bool has_skipauth,bool skipauth,bool has_tls,bool tls,Error **errp)
stubs/Makefile.objs +0 -2
@@ -1,7 +1,5 @@ stub-obj-y += arch-query-cpu-def.o stub-obj-y += arch-query-cpu-model-expansion.o -stub-obj-y += arch-query-cpu-model-comparison.o -stub-obj-y += arch-query-cpu-model-baseline.o stub-obj-y += bdrv-next-monitor-owned.o stub-obj-y += blk-commit-all.o stub-obj-y += blockdev-close-all-bdrv-states.o
stubs/arch-query-cpu-model-baseline.c deleted +0 -13
@@ -1,13 +0,0 @@ -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "sysemu/arch_init.h" -#include "qapi/error.h" -#include "qapi/qmp/qerror.h" - -CpuModelBaselineInfo *arch_query_cpu_model_baseline (CpuModelInfo *modela, -CpuModelInfo *modelb, -Error **errp) -{ -error_setg (errp,QERR_UNSUPPORTED ); -return NULL ; -}
stubs/arch-query-cpu-model-comparison.c deleted +0 -13
@@ -1,13 +0,0 @@ -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "sysemu/arch_init.h" -#include "qapi/error.h" -#include "qapi/qmp/qerror.h" - -CpuModelCompareInfo *arch_query_cpu_model_comparison (CpuModelInfo *modela, -CpuModelInfo *modelb, -Error **errp) -{ -error_setg (errp,QERR_UNSUPPORTED ); -return NULL ; -}
target/s390x/cpu_models.c +3 -2
@@ -25,6 +25,7 @@#include "sysemu/arch_init.h" #include "hw/pci/pci.h" #endif +#include "qapi/qapi-commands-target.h" #define CPUDEF_INIT (_type, _gen, _ec_ga, _mha_pow, _hmfai, _name, _desc) \ { \
@@ -605,7 +606,7 @@ static void list_add_feat(const char *name, void *opaque) *last = entry; } -CpuModelCompareInfo *arch_query_cpu_model_comparison (CpuModelInfo *infoa, +CpuModelCompareInfo *qmp_query_cpu_model_comparison (CpuModelInfo *infoa,CpuModelInfo *infob,Error **errp) {
@@ -678,7 +679,7 @@ CpuModelCompareInfo *arch_query_cpu_model_comparison(CpuModelInfo *infoa,return compare_info; } -CpuModelBaselineInfo *arch_query_cpu_model_baseline (CpuModelInfo *infoa, +CpuModelBaselineInfo *qmp_query_cpu_model_baseline (CpuModelInfo *infoa,CpuModelInfo *infob,Error **errp) {
Signature · 1 line
2.17.2
RFC PATCH v2 8/15 target.json: add a note about query-cpu* not being s390x-specific
In reply to Markus ArmbrusterFrom: Marc-André Lureau <[email protected]>
--- qapi/target.json | 6 ++++++ 1 file changed, 6 insertions(+)
qapi/target.json +6 -0
@@ -275,6 +275,9 @@ # an unknown cpu definition name, unknown properties or properties # with wrong types. # +# Note: this command isn't specific to s390x, but is only implemented +# on this architecture currently. +# # Since: 2.8.0 ## { 'command': 'query-cpu-model-comparison',
@@ -315,6 +318,9 @@ # an unknown cpu definition name, unknown properties or properties # with wrong types. # +# Note: this command isn't specific to s390x, but is only implemented +# on this architecture currently. +# # Since: 2.8.0 ## { 'command': 'query-cpu-model-baseline',
Signature · 1 line
2.17.2
RFC PATCH v2 9/15 qapi: make query-gic-capabilities depend on TARGET_ARM
In reply to Markus ArmbrusterFrom: Marc-André Lureau <[email protected]>
--- monitor.c | 11 ----------- qapi/misc.json | 43 ------------------------------------------ qapi/target.json | 45 ++++++++++++++++++++++++++++++++++++++++++++ target/arm/monitor.c | 2 +- 4 files changed, 46 insertions(+), 55 deletions(-)
monitor.c +0 -11
@@ -1145,9 +1145,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data,*/ static void qmp_unregister_commands_hack (void ) { -#ifndef TARGET_ARM -qmp_unregister_command (&qmp_commands,"query-gic-capabilities" ); -#endif #if !defined(TARGET_S390X ) && !defined(TARGET_I386 )qmp_unregister_command (&qmp_commands,"query-cpu-model-expansion" );#endif
@@ -4658,14 +4655,6 @@ QemuOptsList qemu_mon_opts = { }, }; -#ifndef TARGET_ARM -GICCapabilityList *qmp_query_gic_capabilities (Error **errp) -{ -error_setg (errp,QERR_FEATURE_DISABLED ,"query-gic-capabilities" ); -return NULL ; -} -#endif -HotpluggableCPUList *qmp_query_hotpluggable_cpus (Error **errp) {MachineState *ms =MACHINE (qdev_get_machine ());
qapi/misc.json +0 -43
49 lines not on this page · raw message
qapi/target.json +45 -0
48 lines not on this page · raw message
target/arm/monitor.c +1 -1
@@ -23,7 +23,7 @@#include "qemu/osdep.h" #include "hw/boards.h" #include "kvm_arm.h" -#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-target.h" static GICCapability *gic_cap_new (int version) {
Signature · 1 line
2.17.2
RFC PATCH v2 10/15 qapi: make query-cpu-model-expansion depend on s390 or x86
In reply to Markus ArmbrusterFrom: Marc-André Lureau <[email protected]>
--- include/sysemu/arch_init.h | 3 -- monitor.c | 3 -- qapi/misc.json | 51 ------------------------- qapi/target.json | 52 ++++++++++++++++++++++++++ qmp.c | 7 ---- stubs/Makefile.objs | 1 - stubs/arch-query-cpu-model-expansion.c | 13 ------- target/i386/cpu.c | 5 ++- target/s390x/cpu_models.c | 2 +- 9 files changed, 57 insertions(+), 80 deletions(-) delete mode 100644 stubs/arch-query-cpu-model-expansion.c
include/sysemu/arch_init.h +0 -3
@@ -33,7 +33,4 @@ int kvm_available(void);int xen_available (void );CpuDefinitionInfoList *arch_query_cpu_definitions (Error **errp); -CpuModelExpansionInfo *arch_query_cpu_model_expansion (CpuModelExpansionType type, -CpuModelInfo *mode, -Error **errp);#endif
monitor.c +0 -3
@@ -1145,9 +1145,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data,*/ static void qmp_unregister_commands_hack (void ) { -#if !defined(TARGET_S390X ) && !defined(TARGET_I386 ) -qmp_unregister_command (&qmp_commands,"query-cpu-model-expansion" ); -#endif #if !defined(TARGET_PPC ) && !defined(TARGET_ARM ) && !defined(TARGET_I386 ) \ && !defined(TARGET_S390X )qmp_unregister_command (&qmp_commands,"query-cpu-definitions" );
qapi/misc.json +0 -51
57 lines not on this page · raw message
qapi/target.json +52 -0
55 lines not on this page · raw message
qmp.c +0 -7
@@ -610,13 +610,6 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)return arch_query_cpu_definitions (errp); } -CpuModelExpansionInfo *qmp_query_cpu_model_expansion (CpuModelExpansionType type, -CpuModelInfo *model, -Error **errp) -{ -return arch_query_cpu_model_expansion (type, model, errp); -} -void qmp_add_client (const char *protocol,const char *fdname,bool has_skipauth,bool skipauth,bool has_tls,bool tls,Error **errp)
stubs/Makefile.objs +0 -1
@@ -1,5 +1,4 @@ stub-obj-y += arch-query-cpu-def.o -stub-obj-y += arch-query-cpu-model-expansion.o stub-obj-y += bdrv-next-monitor-owned.o stub-obj-y += blk-commit-all.o stub-obj-y += blockdev-close-all-bdrv-states.o
stubs/arch-query-cpu-model-expansion.c deleted +0 -13
@@ -1,13 +0,0 @@ -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "sysemu/arch_init.h" -#include "qapi/error.h" -#include "qapi/qmp/qerror.h" - -CpuModelExpansionInfo *arch_query_cpu_model_expansion (CpuModelExpansionType type, -CpuModelInfo *mode, -Error **errp) -{ -error_setg (errp,QERR_UNSUPPORTED ); -return NULL ; -}
target/i386/cpu.c +4 -1
@@ -41,6 +41,7 @@#include "qapi/visitor.h" #include "qom/qom-qobject.h" #include "sysemu/arch_init.h" +#include "qapi/qapi-commands-target.h" #include "standard-headers/asm-x86/kvm_para.h"
@@ -3880,6 +3881,7 @@ static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefinition *def, Error **errp) } +#ifndef CONFIG_USER_ONLY /* Return a QDict containing keys for all properties that can be included * in static expansion of CPU models. All properties set by x86_cpu_load_def() * must be included in the dictionary.
@@ -4027,7 +4029,7 @@ out: }CpuModelExpansionInfo * -arch_query_cpu_model_expansion (CpuModelExpansionType type, +qmp_query_cpu_model_expansion (CpuModelExpansionType type,CpuModelInfo *model,Error **errp) {
@@ -4082,6 +4084,7 @@ out: }return ret; } +#endif /* !CONFIG_USER_ONLY */ static gchar *x86_gdb_arch_name (CPUState *cs) {
target/s390x/cpu_models.c +1 -1
@@ -567,7 +567,7 @@ static void cpu_info_from_model(CpuModelInfo *info, const S390CPUModel *model, } } -CpuModelExpansionInfo *arch_query_cpu_model_expansion (CpuModelExpansionType type, +CpuModelExpansionInfo *qmp_query_cpu_model_expansion (CpuModelExpansionType type,CpuModelInfo *model,Error **errp) {
Signature · 1 line
2.17.2
RFC PATCH v2 11/15 qapi: make query-cpu-definitions depend on specific targets
In reply to Markus ArmbrusterFrom: Marc-André Lureau <[email protected]>
It depends on TARGET_PPC || TARGET_ARM || TARGET_I386 || TARGET_S390X.
--- include/sysemu/arch_init.h | 1 - monitor.c | 22 ------------ qapi/misc.json | 58 ------------------------------ qapi/target.json | 64 +++++++++++++++++++++++++++++++++ qmp.c | 5 --- stubs/Makefile.objs | 1 - stubs/arch-query-cpu-def.c | 11 ------ target/arm/helper.c | 3 +- target/i386/cpu.c | 2 +- target/ppc/translate_init.inc.c | 3 +- target/s390x/cpu_models.c | 2 +- 11 files changed, 70 insertions(+), 102 deletions(-) delete mode 100644 stubs/arch-query-cpu-def.c
include/sysemu/arch_init.h +0 -1
@@ -32,5 +32,4 @@ extern const uint32_t arch_type;int kvm_available (void );int xen_available (void ); -CpuDefinitionInfoList *arch_query_cpu_definitions (Error **errp);#endif
monitor.c +0 -22
@@ -1131,26 +1131,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data, *ret_data =qobject_from_qlit (&qmp_schema_qlit); } -/* -* We used to define commands in qmp-commands.hx in addition to the -* QAPI schema. This permitted defining some of them only in certain -* configurations. query-commands has always reflected that (good, -* because it lets QMP clients figure out what's actually available), -* while query-qmp-schema never did (not so good). This function is a -* hack to keep the configuration-specific commands defined exactly as -* before, even though qmp-commands.hx is gone. -* -* FIXME Educate the QAPI schema on configuration-specific commands, -* and drop this hack. -*/ -static void qmp_unregister_commands_hack (void ) -{ -#if !defined(TARGET_PPC ) && !defined(TARGET_ARM ) && !defined(TARGET_I386 ) \ - && !defined(TARGET_S390X ) -qmp_unregister_command (&qmp_commands,"query-cpu-definitions" ); -#endif -} -static void monitor_init_qmp_commands (void ) {/*
@@ -1169,8 +1149,6 @@ static void monitor_init_qmp_commands(void)qmp_register_command (&qmp_commands,"netdev_add" , qmp_netdev_add,QCO_NO_OPTIONS ); -qmp_unregister_commands_hack (); -QTAILQ_INIT (&qmp_cap_negotiation_commands);qmp_register_command (&qmp_cap_negotiation_commands,"qmp_capabilities" , qmp_marshal_qmp_capabilities,QCO_ALLOW_PRECONFIG );
qapi/misc.json +0 -58
70 lines not on this page · raw message
qapi/target.json +64 -0
67 lines not on this page · raw message
qmp.c +0 -5
@@ -605,11 +605,6 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename,return prop_list; } -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) -{ -return arch_query_cpu_definitions (errp); -} -void qmp_add_client (const char *protocol,const char *fdname,bool has_skipauth,bool skipauth,bool has_tls,bool tls,Error **errp)
stubs/Makefile.objs +0 -1
@@ -1,4 +1,3 @@ -stub-obj-y += arch-query-cpu-def.o stub-obj-y += bdrv-next-monitor-owned.o stub-obj-y += blk-commit-all.o stub-obj-y += blockdev-close-all-bdrv-states.o
stubs/arch-query-cpu-def.c deleted +0 -11
@@ -1,11 +0,0 @@ -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "sysemu/arch_init.h" -#include "qapi/error.h" -#include "qapi/qmp/qerror.h" - -CpuDefinitionInfoList *arch_query_cpu_definitions (Error **errp) -{ -error_setg (errp,QERR_UNSUPPORTED ); -return NULL ; -}
target/arm/helper.c +2 -1
@@ -18,6 +18,7 @@#include "sysemu/kvm.h" #include "fpu/softfloat.h" #include "qemu/range.h" +#include "qapi/qapi-commands-target.h" #define ARM_CPU_FREQ 1000000000/* FIXME: 1 GHz, should be configurable */
@@ -5938,7 +5939,7 @@ static void arm_cpu_add_definition(gpointer data, gpointer user_data) *cpu_list = entry; } -CpuDefinitionInfoList *arch_query_cpu_definitions (Error **errp) +CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) {CpuDefinitionInfoList *cpu_list =NULL ;GSList *list;
target/i386/cpu.c +1 -1
@@ -3753,7 +3753,7 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data) *cpu_list = entry; } -CpuDefinitionInfoList *arch_query_cpu_definitions (Error **errp) +CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) {CpuDefinitionInfoList *cpu_list =NULL ;GSList *list =get_sorted_cpu_model_list ();
target/ppc/translate_init.inc.c +2 -1
@@ -38,6 +38,7 @@#include "qemu/cutils.h" #include "disas/capstone.h" #include "fpu/softfloat.h" +#include "qapi/qapi-commands-target.h" //#define PPC_DUMP_CPU //#define PPC_DEBUG_SPR
@@ -10207,7 +10208,7 @@ static void ppc_cpu_defs_entry(gpointer data, gpointer user_data) *first = entry; } -CpuDefinitionInfoList *arch_query_cpu_definitions (Error **errp) +CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) {CpuDefinitionInfoList *cpu_list =NULL ;GSList *list;
target/s390x/cpu_models.c +1 -1
@@ -433,7 +433,7 @@ static void create_cpu_model_list(ObjectClass *klass, void *opaque) *cpu_list = entry; } -CpuDefinitionInfoList *arch_query_cpu_definitions (Error **errp) +CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) {struct CpuDefinitionInfoListData list_data = { .list =NULL ,
Signature · 1 line
2.17.2
RFC PATCH v2 12/15 qapi: remove qmp_unregister_command()
In reply to Markus ArmbrusterFrom: Marc-André Lureau <[email protected]>
This command is no longer needed, the schema has compile-time configuration conditions.
--- include/qapi/qmp/dispatch.h | 1 - qapi/qmp-registry.c | 8 -------- 2 files changed, 9 deletions(-)
include/qapi/qmp/dispatch.h +0 -1
@@ -39,7 +39,6 @@ typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpCommandList;void qmp_register_command (QmpCommandList *cmds,const char *name,QmpCommandFunc *fn,QmpCommandOptions options); -void qmp_unregister_command (QmpCommandList *cmds,const char *name);QmpCommand *qmp_find_command (QmpCommandList *cmds,const char *name);void qmp_disable_command (QmpCommandList *cmds,const char *name);void qmp_enable_command (QmpCommandList *cmds,const char *name);
qapi/qmp-registry.c +0 -8
@@ -27,14 +27,6 @@ void qmp_register_command(QmpCommandList *cmds, const char *name,QTAILQ_INSERT_TAIL (cmds, cmd, node); } -void qmp_unregister_command (QmpCommandList *cmds,const char *name) -{ -QmpCommand *cmd =qmp_find_command (cmds, name); - -QTAILQ_REMOVE (cmds, cmd, node); -g_free (cmd); -} -QmpCommand *qmp_find_command (QmpCommandList *cmds,const char *name) {QmpCommand *cmd;
Signature · 1 line
2.17.2
RFC PATCH v2 13/15 Revert "qapi-events: add 'if' condition to implicit event enum"
In reply to Markus ArmbrusterThis reverts commit 7bd263490590ee6fcf34ecb6203437e22f6e5a9c.
The commit applied the events' conditions to the members of enum QAPIEvent. Awkward, because it renders QAPIEvent unusable in target-independent code as soon as we make an event target-dependent. Reverting this has the following effects:
* ui/vnc.c can remain target independent.
* monitor_qapi_event_conf[] doesn't have to muck around with #ifdef.
* query-events again doesn't reflect conditionals. I'm going to deprecate it in favor of query-qmp-schema.
# Conflicts:
# scripts/qapi/events.py
--- scripts/qapi/events.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/qapi/events.py +3 -1
@@ -194,7 +194,9 @@ void %(event_emit)s(%(event_enum)s event, QDict *qdict); self._genc.add(gen_event_send(name, arg_type, boxed, self._event_enum_name, self._event_emit_name)) - self._event_enum_members.append(QAPISchemaMember(name, ifcond)) + # Note: we generate the enum member regardless of @ifcond, to + # keep the enumeration usable in target-independent code. + self._event_enum_members.append(QAPISchemaMember(name)) def gen_events(schema, output_dir, prefix):
Signature · 1 line
2.17.2
Re: [Qemu-devel] [RFC PATCH v2 13/15] Revert "qapi-events: add 'if' condition to implicit event enum"
Hi
Quoted 9 lines · Markus Armbruster
This reverts commit
7bd263490590ee6fcf34ecb6203437e22f6e5a9c.The commit applied the events' conditions to the members of enum QAPIEvent. Awkward, because it renders QAPIEvent unusable in target-independent code as soon as we make an event target-dependent. Reverting this has the following effects:
*
ui/vnc.ccan remain target independent.
Was it ever moved? I don't recall
Quoted 2 lines
* monitor_qapi_event_conf[] doesn't have to muck around with #ifdef.
I suggested a way to get rid of monitor_qapi_event_conf[] in the patch message, by having the rate stored in the schema, which could actually be useful (for doc, introspection etc).
Quoted 3 lines
* query-events again doesn't reflect conditionals. I'm going to deprecate it in favor of query-qmp-schema.
I guess that's not that important.
I have a slight preference for not declaring enums when the related option is disabled.
But people don't like having too much #ifdef code, which is understandable.
Quoted 28 lines
Signed-off-by Markus Armbruster <[email protected]># Conflicts:
#scripts/qapi/events.py--- scripts/qapi/events.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)scripts/qapi/events.py +3
-2@@ -194,7 +194,9 @@ void %(event_emit)s(%(event_enum)s event, QDict *qdict); self._genc.add(gen_event_send(name, arg_type, boxed, self._event_enum_name, self._event_emit_name)) - self._event_enum_members.append(QAPISchemaMember(name, ifcond)) + # Note: we generate the enum member regardless of @ifcond, to + # keep the enumeration usable in target-independent code. + self._event_enum_members.append(QAPISchemaMember(name)) def gen_events(schema, output_dir, prefix): --2.17.2
Signature · 1 line
Marc-André Lureau
Re: [Qemu-devel] [RFC PATCH v2 13/15] Revert "qapi-events: add 'if' condition to implicit event enum"
Quoted 6 lines · Marc-André Lureau
Hi
Quoted 3 lines · Markus Armbruster
This reverts commit
7bd263490590ee6fcf34ecb6203437e22f6e5a9c.
Quoted 8 lines
Quoted 6 lines
The commit applied the events' conditions to the members of enum QAPIEvent. Awkward, because it renders QAPIEvent unusable in target-independent code as soon as we make an event target-dependent. Reverting this has the following effects:
*
ui/vnc.ccan remain target independent.Was it ever moved? I don't recall
It's currently target-independent, and we want it to remain that way.
You keep it that way by splitting target-dependent target_QAPIEvent off QAPIEvent.
I keep it that way by not making any enum members target-dependent.
Quoted 5 lines
Quoted 1 line
* monitor_qapi_event_conf[] doesn't have to muck around with #ifdef.
I suggested a way to get rid of monitor_qapi_event_conf[] in the patch message, by having the rate stored in the schema, which could actually be useful (for doc, introspection etc).
Introspection and generated documentation improvements might still make that worthwhile. For the former, we'd first want an actual user, though.
Quoted 4 lines
Quoted 2 lines
* query-events again doesn't reflect conditionals. I'm going to deprecate it in favor of query-qmp-schema.
I guess that's not that important.
query-qmp-schema has reflected conditionals since we introduced them in v3.0. query-events has not. Your commit fixes it for 4.0. Fixes are good, but when an interface is known to be deficient in some versions, while a strictly more powerful buddy is fine in all versions, the obvious thing to do is to stay away from the deficient one regardless of version.
I think we should deprecate query-events even if we decide to fix it now.
I'll work this into the next commit's commit message.
Quoted 2 lines
I have a slight preference for not declaring enums when the related option is disabled.
Me too, but I like keeping things simple even more.
Possibly even simpler: dispense with the enumeration type, add suitable #define to each qapi-event-MODULE.h. We can have #ifdef there. What do you think?
Quoted 1 line
But people don't like having too much #ifdef code, which is understandable.
In this case, it's just one big #if in monitor.c. Tolerable, I think.
If we replace QAPIEvent by #define, the #if shrinks to just #ifdef QAPI_EVENT_RTC_CHANGE.
Note that monitor.c is already target-dependent. It should really be split up, though. The #if would keep the QMP part target-dependent, unless we split it up even more. Hmm.
Quoted 27 lines
Quoted 27 lines
Signed-off-by Markus Armbruster <[email protected]># Conflicts:
#scripts/qapi/events.py--- scripts/qapi/events.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)scripts/qapi/events.py +3
-2@@ -194,7 +194,9 @@ void %(event_emit)s(%(event_enum)s event, QDict *qdict); self._genc.add(gen_event_send(name, arg_type, boxed, self._event_enum_name, self._event_emit_name)) - self._event_enum_members.append(QAPISchemaMember(name, ifcond)) + # Note: we generate the enum member regardless of @ifcond, to + # keep the enumeration usable in target-independent code. + self._event_enum_members.append(QAPISchemaMember(name)) def gen_events(schema, output_dir, prefix): --2.17.2
RFC PATCH v2 14/15 qmp: Deprecate query-events in favor of query-qmp-schema
In reply to Markus Armbrusterquery-events doesn't reflect compile-time configuration. Instead of fixing that, deprecate the command in favor of query-qmp-schema.
--- monitor.c | 5 +++++ qapi/misc.json | 7 +++++-- qemu-deprecated.texi | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-)
monitor.c +5 -0
@@ -1099,6 +1099,11 @@ CommandInfoList *qmp_query_commands(Error **errp)EventInfoList *qmp_query_events (Error **errp) { +/* +* TODO This deprecated command is the only user of +* QAPIEvent_str() and QAPIEvent_lookup[]. When the command goes, +* they should go, too. +*/ EventInfoList *info, *ev_list =NULL ;QAPIEvent e;
qapi/misc.json +5 -2
@@ -318,12 +318,15 @@ ## # @query-events: # -# Return a list of supported QMP events by this server +# Return information on QMP events. # -# Returns: A list of @EventInfo for all supported events +# Returns: A list of @EventInfo. # # Since: 1.2.0 # +# Note: This command is deprecated, because its output doesn't reflect +# compile-time configuration. Use query-qmp-schema instead. +# # Example: # # -> { "execute": "query-events" }
qemu-deprecated.texi +5 -0
@@ -106,6 +106,11 @@ The ``query-cpus'' command is replaced by the ``query-cpus-fast'' command. The ``arch'' output member of the ``query-cpus-fast'' command is replaced by the ``target'' output member. +@subsection query-events + +The ``query-events'' command has been superseded by the more powerful +and accurate ``query-qmp-schema'' command. + @section System emulator human monitor commands @subsection The hub_id parameter of 'hostfwd_add' / 'hostfwd_remove' (since 3.1)
Signature · 1 line
2.17.2
Re: [Qemu-devel] [RFC PATCH v2 14/15] qmp: Deprecate query-events in favor of query-qmp-schema
Hi
Quoted 5 lines · Markus Armbruster
query-events doesn't reflect compile-time configuration. Instead of fixing that, deprecate the command in favor of query-qmp-schema.
Signed-off-by Markus Armbruster <[email protected]>
Quoted 64 lines
--- monitor.c | 5 +++++ qapi/misc.json | 7 +++++-- qemu-deprecated.texi | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-)monitor.c +5
-0@@ -1099,6 +1099,11 @@ CommandInfoList *qmp_query_commands(Error **errp)EventInfoList *qmp_query_events (Error **errp) { +/* +* TODO This deprecated command is the only user of +* QAPIEvent_str() and QAPIEvent_lookup[]. When the command goes, +* they should go, too. +*/ EventInfoList *info, *ev_list =NULL ;QAPIEvent e;qapi/misc.json +5
-2@@ -318,12 +318,15 @@ ## # @query-events: # -# Return a list of supported QMP events by this server +# Return information on QMP events. # -# Returns: A list of @EventInfo for all supported events +# Returns: A list of @EventInfo. # # Since: 1.2.0 # +# Note: This command is deprecated, because its output doesn't reflect +# compile-time configuration. Use query-qmp-schema instead. +# # Example: # # -> { "execute": "query-events" }qemu-deprecated.texi +5
-1@@ -106,6 +106,11 @@ The ``query-cpus'' command is replaced by the ``query-cpus-fast'' command. The ``arch'' output member of the ``query-cpus-fast'' command is replaced by the ``target'' output member. +@subsection query-events + +The ``query-events'' command has been superseded by the more powerful +and accurate ``query-qmp-schema'' command. + @section System emulator human monitor commands @subsection The hub_id parameter of 'hostfwd_add' / 'hostfwd_remove' (since 3.1) --2.17.2
Signature · 1 line
Marc-André Lureau
RFC PATCH v2 15/15 qapi: move RTC_CHANGE to the target schema
In reply to Markus ArmbrusterFrom: Marc-André Lureau <[email protected]>
A few targets don't emit RTC_CHANGE, we could restrict the event to the tagets that do emit it.
Note: There is a lot more of events & commands that we could restrict to capable targets, with the cost of some additional complexity, but the benefit of added correctness and better introspection.
--- hw/ppc/spapr_rtc.c | 2 +- hw/timer/mc146818rtc.c | 2 +- qapi/misc.json | 23 ----------------------- qapi/target.json | 23 +++++++++++++++++++++++ 4 files changed, 25 insertions(+), 25 deletions(-)
hw/ppc/spapr_rtc.c +1 -1
@@ -31,7 +31,7 @@#include "sysemu/sysemu.h" #include "hw/ppc/spapr.h" #include "qapi/error.h" -#include "qapi/qapi-events-misc.h" +#include "qapi/qapi-events-target.h" #include "qemu/cutils.h" void spapr_rtc_read (sPAPRRTCState *rtc,struct tm *tm,uint32_t *ns)
hw/timer/mc146818rtc.c +1 -1
@@ -32,7 +32,7 @@#include "hw/timer/mc146818rtc.h" #include "qapi/error.h" #include "qapi/qapi-commands-target.h" -#include "qapi/qapi-events-misc.h" +#include "qapi/qapi-events-target.h" #include "qapi/visitor.h" #include "exec/address-spaces.h"
qapi/misc.json +0 -23
@@ -2840,29 +2840,6 @@ { 'event': 'ACPI_DEVICE_OST', 'data': { 'info': 'ACPIOSTInfo' } } -## -# @RTC_CHANGE: -# -# Emitted when the guest changes the RTC time. -# -# @offset: offset between base RTC clock (as specified by -rtc base), and -# new RTC clock value. Note that value will be different depending -# on clock chosen to drive RTC (specified by -rtc clock). -# -# Note: This event is rate-limited. -# -# Since: 0.13.0 -# -# Example: -# -# <- { "event": "RTC_CHANGE", -# "data": { "offset": 78 }, -# "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } -# -## -{ 'event': 'RTC_CHANGE', - 'data': { 'offset': 'int' } } - ## # @ReplayMode: #
qapi/target.json +23 -0
@@ -7,6 +7,29 @@ { 'include': 'misc.json' } +## +# @RTC_CHANGE: +# +# Emitted when the guest changes the RTC time. +# +# @offset: offset between base RTC clock (as specified by -rtc base), and +# new RTC clock value +# +# Note: This event is rate-limited. +# +# Since: 0.13.0 +# +# Example: +# +# <- { "event": "RTC_CHANGE", +# "data": { "offset": 78 }, +# "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } +# +## +{ 'event': 'RTC_CHANGE', + 'data': { 'offset': 'int' }, + 'if': 'defined(TARGET_ALPHA) || defined(TARGET_ARM) || defined(TARGET_HPPA) || defined(TARGET_I386) || defined(TARGET_MIPS) || defined(TARGET_MIPS64) || defined(TARGET_MOXIE) || defined(TARGET_PPC) || defined(TARGET_PPC64) || defined(TARGET_S390X) || defined(TARGET_SH4) || defined(TARGET_SPARC)' } + ## # @rtc-reset-reinjection: #
Signature · 1 line
2.17.2
Hi
Quoted 20 lines · Markus Armbruster
Marc-André posted v1 that relies on a QAPI schema language extension 'top-unit' to permit splitting the generated code. Here is his cover letter:
The thrid and last part (of "[PATCH v2 00/54] qapi: add #if pre-processor conditions to generated code") is about adding schema conditions based on the target.
For now, the qapi code is compiled in common objects (common to all targets). This makes it impossible to add #if
TARGET_ARMfor example.The patch "RFC: qapi: learn to split the schema by 'top-unit'" proposes to split the schema by "top-unit", so that generated code can be built either in common objects or per-target. That patch is a bit rough, I would like to get some feedback about the approach before trying to improve it. The following patches demonstrate usage of target-based #if conditions, and getting rid of the
qmp_unregister_command()hack.
Quoted 6 lines
We already have a way to split generated code: QAPI modules. I took the liberty to rework Marc-André's series to use a target module instead. Less code, no change to the QAPI language.
One of the patches (marked WIP) is a total hack. Fixable, but I want to get this out for discussion first.
The approach you propose includes -target.h header in the top headers, effectively making all the qapi code target-dependent, no? I am actually a bit surprised there are no poisoined define errors. Possibly because the top-level header is rarely included.
By contrast, my approach has the advantage of a clean split between target and non-target dependent code, which I would feel more confident about.
That's the reason why I promptly discarded the QAPI modules approach without having second thoughts at least. Now you force me to reconsider it though.
Quoted 66 lines
Marc-André Lureau (9):
build-sys: move qmp-introspect per target
qapi: make rtc-reset-reinjection and SEV depend onTARGET_I386
qapi: make s390 commands depend onTARGET_S390Xtarget.json: add a note about query-cpu* not being s390x-specific
qapi: make query-gic-capabilities depend onTARGET_ARM
qapi: make query-cpu-model-expansion depend on s390 or x86
qapi: make query-cpu-definitions depend on specific targets
qapi: removeqmp_unregister_command()
qapi: moveRTC_CHANGEto the target schemaMarkus Armbruster (6):
qapi: Belatedly update docs for commit9c2f56e9f9d
qapi: Eliminate indirection throughqmp_event_get_func_emit()
qapi: Generate QAPIEvent stuff into separate files WIP
qapi: New module target.json
Revert "qapi-events: add 'if' condition to implicit event enum"
qmp: Deprecate query-events in favor of query-qmp-schemaMakefile | 1 + Makefile.objs | 22 +- Makefile.target | 12 + docs/devel/qapi-code-gen.txt | 12 +- hw/ppc/spapr_rtc.c | 2 +- hw/s390x/s390-skeys.c | 2 +- hw/timer/mc146818rtc.c | 4 +- include/qapi/qmp-event.h | 6 - include/qapi/qmp/dispatch.h | 1 - include/sysemu/arch_init.h | 11 - monitor.c | 92 +---- qapi/misc.json | 485 +--------------------- qapi/qapi-schema.json | 1 + qapi/qmp-event.c | 12 - qapi/qmp-registry.c | 8 - qapi/target.json | 514 ++++++++++++++++++++++++ qemu-deprecated.texi | 5 + qmp.c | 26 -- scripts/qapi/events.py | 51 ++- stubs/Makefile.objs | 4 - stubs/arch-query-cpu-def.c | 11 - stubs/arch-query-cpu-model-baseline.c | 13 - stubs/arch-query-cpu-model-comparison.c | 13 - stubs/arch-query-cpu-model-expansion.c | 13 - stubs/monitor.c | 5 + target/arm/helper.c | 3 +- target/arm/monitor.c | 2 +- target/i386/cpu.c | 7 +- target/i386/sev_i386.h | 2 +- target/ppc/translate_init.inc.c | 3 +- target/s390x/cpu_models.c | 9 +- tests/Makefile.include | 4 +- tests/test-qmp-event.c | 7 +- tests/test-qobject-input-visitor.c | 1 - ui/vnc.c | 3 +- 35 files changed, 623 insertions(+), 744 deletions(-) create mode 100644 qapi/target.json delete mode 100644 stubs/arch-query-cpu-def.c delete mode 100644 stubs/arch-query-cpu-model-baseline.c delete mode 100644 stubs/arch-query-cpu-model-comparison.c delete mode 100644 stubs/arch-query-cpu-model-expansion.c--
2.17.2
Signature · 1 line
Marc-André Lureau
Quoted 27 lines · Marc-André Lureau
Hi
Quoted 24 lines · Markus Armbruster
Marc-André posted v1 that relies on a QAPI schema language extension 'top-unit' to permit splitting the generated code. Here is his cover letter:
The thrid and last part (of "[PATCH v2 00/54] qapi: add #if pre-processor conditions to generated code") is about adding schema conditions based on the target.
For now, the qapi code is compiled in common objects (common to all targets). This makes it impossible to add #if
TARGET_ARMfor example.The patch "RFC: qapi: learn to split the schema by 'top-unit'" proposes to split the schema by "top-unit", so that generated code can be built either in common objects or per-target. That patch is a bit rough, I would like to get some feedback about the approach before trying to improve it. The following patches demonstrate usage of target-based #if conditions, and getting rid of the
qmp_unregister_command()hack.We already have a way to split generated code: QAPI modules. I took the liberty to rework Marc-André's series to use a target module instead. Less code, no change to the QAPI language.
Quoted 5 lines
Quoted 2 lines
One of the patches (marked WIP) is a total hack. Fixable, but I want to get this out for discussion first.
The approach you propose includes
-target.hheader in the top headers, effectively making all the qapi code target-dependent, no?
Yes, but...
Quoted 2 lines
I am actually a bit surprised there are no poisoined define errors. Possibly because the top-level header is rarely included.
... next to nothing includes the top-level header:
$ git-grep -E 'include.*"(qapi/)?qapi-[^-]*.h'
monitor.c:#include "qapi/qapi-commands.h"Here we actually need all commands, complete with their target-dependence.
monitor.c:#include "qapi/qapi-introspect.h" tests/test-qobject-input-visitor.c:#include "qapi/qapi-introspect.h"
qapi-introspect.[ch] are monolithic.
ui/cocoa.m:#include "qapi/qapi-commands.h"
This is just lazy; we should include just the qapi-commands-FOO we actually need. I'll ask the maintainer for help with cleaning this up.
Including top-level headers has been a bad idea ever since we generate modular headers (commit 252dc3105fc), because it leads to "touch the QAPI schema, have some coffee while the world is recompiled".
Adding target-dependent conditionals makes this bad idea impractical in target-independent code. Feature!
Quoted 7 lines
By contrast, my approach has the advantage of a clean split between target and non-target dependent code, which I would feel more confident about.
That's the reason why I promptly discarded the QAPI modules approach without having second thoughts at least. Now you force me to reconsider it though.
Please do :)
Quoted 19 lines · Markus Armbruster
Marc-André posted v1 that relies on a QAPI schema language extension 'top-unit' to permit splitting the generated code. Here is his cover letter:
The thrid and last part (of "[PATCH v2 00/54] qapi: add #if pre-processor conditions to generated code") is about adding schema conditions based on the target.
For now, the qapi code is compiled in common objects (common to all targets). This makes it impossible to add #if
TARGET_ARMfor example.The patch "RFC: qapi: learn to split the schema by 'top-unit'" proposes to split the schema by "top-unit", so that generated code can be built either in common objects or per-target. That patch is a bit rough, I would like to get some feedback about the approach before trying to improve it. The following patches demonstrate usage of target-based #if conditions, and getting rid of the
qmp_unregister_command()hack.
Quoted 6 lines
We already have a way to split generated code: QAPI modules. I took the liberty to rework Marc-André's series to use a target module instead. Less code, no change to the QAPI language.
One of the patches (marked WIP) is a total hack. Fixable, but I want to get this out for discussion first.
PATCH 01-02 make sense on their own; queued.