qapi: add #if pre-processor conditions to generated code (part 3)
cover qapi: add #if pre-processor conditions to generated code (part 3)
Hi,
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.
Marc-André Lureau (13):
build-sys: move qmp-introspect per target
qapi-commands: don't initialize command list in qmp_init_marshall()
qapi-commands: rename init_marshal() to register_commands()
RFC: qapi: learn to split the schema by 'top-unit'
qapi: add a top-unit 'target' schema
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
qapi/misc.json | 478 ---------------------- qapi/qapi-schema.json | 1 + qapi/target.json | 516 ++++++++++++++++++++++++ scripts/qapi/commands.py | 28 +- scripts/qapi/common.py | 105 ++++- scripts/qapi/events.py | 37 +- scripts/qapi/types.py | 8 +- scripts/qapi/visit.py | 8 +- include/qapi/qmp-event.h | 4 + include/qapi/qmp/dispatch.h | 1 - include/sysemu/arch_init.h | 11 - target/i386/sev_i386.h | 2 +- hw/ppc/spapr_rtc.c | 2 +- hw/s390x/s390-skeys.c | 2 +- hw/timer/mc146818rtc.c | 4 +- monitor.c | 306 +++++++------- qapi/qmp-event.c | 11 + qapi/qmp-registry.c | 8 - qga/main.c | 3 +- qmp.c | 26 -- 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 - target/arm/helper.c | 3 +- target/arm/monitor.c | 2 +- target/i386/cpu.c | 6 +- target/ppc/translate_init.inc.c | 3 +- target/s390x/cpu_models.c | 9 +- tests/test-qmp-cmds.c | 3 +- tests/test-qobject-input-visitor.c | 1 - Makefile | 7 +- Makefile.objs | 2 - Makefile.target | 4 + docs/devel/qapi-code-gen.txt | 6 +- stubs/Makefile.objs | 4 - 36 files changed, 851 insertions(+), 810 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.20.0
PATCH 1/13 build-sys: move qmp-introspect per target
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.
--- tests/test-qobject-input-visitor.c | 1 - Makefile.objs | 2 -- Makefile.target | 2 ++ 3 files changed, 2 insertions(+), 3 deletions(-)
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)
Makefile.objs +0 -2
@@ -13,7 +13,6 @@ util-obj-y += qapi/qapi-visit.o util-obj-y += $(QAPI_MODULES:%=qapi/qapi-visit-%.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/
@@ -94,7 +93,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)
Signature · 1 line
2.20.0
Re: [Qemu-devel] [PATCH 01/13] build-sys: move qmp-introspect per target
Quoted 54 lines · Marc-André Lureau
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.Signed-off-by Marc-André Lureau <[email protected]>--- tests/test-qobject-input-visitor.c | 1 - Makefile.objs | 2 -- Makefile.target | 2 ++ 3 files changed, 2 insertions(+), 3 deletions(-)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)Makefile.objs +0
-2@@ -13,7 +13,6 @@ util-obj-y += qapi/qapi-visit.o util-obj-y += $(QAPI_MODULES:%=qapi/qapi-visit-%.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/@@ -94,7 +93,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 endifMakefile.target +0
-0
Makefile.target endif · line 163
Quoted 8 lines
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)
Having to compile this multiple times is a bit sad, since it's fairly big:
$ ls -lh qapi/qapi-introspect.c -rw-rw-r--. 1 armbru armbru 518K Dec 17 07:56 qapi/qapi-introspect.c $ size x86_64-softmmu/qapi/qapi-introspect.o text data bss dec hex filename 16302 289472 48 305822 4aa9e x86_64-softmmu/qapi/qapi-introspect.o
To compile its target-independent part just once, we'd have to split it up. May or may not improve compile time. We can figure it out when compiling all of it multiple times bother us.
PATCH 2/13 qapi-commands: don't initialize command list in qmp_init_marshall()
In reply to Marc-André LureauThis will let the caller add several list of commands coming from different schemas (the following patches split the schemas for common and arch-specific parts).
--- scripts/qapi/commands.py | 2 -- monitor.c | 1 + qga/main.c | 1 + tests/test-qmp-cmds.c | 1 + docs/devel/qapi-code-gen.txt | 2 -- 5 files changed, 3 insertions(+), 4 deletions(-)
scripts/qapi/commands.py +0 -2
@@ -222,8 +222,6 @@ def gen_registry(registry, prefix): void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds) { - QTAILQ_INIT(cmds); - ''', c_prefix=c_name(prefix, protect=False)) ret += registry
monitor.c +1 -0
@@ -1181,6 +1181,7 @@ static void monitor_init_qmp_commands(void)* "qmp_capabilities", to enforce capability negotiation */ +QTAILQ_INIT (&qmp_commands);qmp_init_marshal (&qmp_commands); qmp_register_command(&qmp_commands, "query-qmp-schema",
qga/main.c +1 -0
@@ -1486,6 +1486,7 @@ int main(int argc, char **argv) config->log_level =G_LOG_LEVEL_ERROR |G_LOG_LEVEL_CRITICAL ; +QTAILQ_INIT (&ga_commands);qga_qmp_init_marshal (&ga_commands);init_dfl_pathnames ();
tests/test-qmp-cmds.c +1 -0
@@ -325,6 +325,7 @@ int main(int argc, char **argv)g_test_add_func ("/qmp/dealloc_types" , test_dealloc_types);g_test_add_func ("/qmp/dealloc_partial" , test_dealloc_partial); +QTAILQ_INIT (&qmp_commands);test_qmp_init_marshal (&qmp_commands);g_test_run ();
docs/devel/qapi-code-gen.txt +0 -2
@@ -1334,8 +1334,6 @@ Example: void example_qmp_init_marshal(QmpCommandList *cmds) { - QTAILQ_INIT(cmds); - qmp_register_command(cmds, "my-command", qmp_marshal_my_command, QCO_NO_OPTIONS); }
Signature · 1 line
2.20.0
PATCH 3/13 qapi-commands: rename init_marshal() to register_commands()
In reply to Marc-André LureauThe function only calls various register_command() now, use a more descriptive name.
--- scripts/qapi/commands.py | 4 ++-- monitor.c | 2 +- qga/main.c | 2 +- tests/test-qmp-cmds.c | 2 +- docs/devel/qapi-code-gen.txt | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-)
scripts/qapi/commands.py +2 -2
@@ -220,7 +220,7 @@ def gen_register_command(name, success_response, allow_oob, allow_preconfig): def gen_registry(registry, prefix): ret = mcgen(''' -void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds) +void %(c_prefix)sqmp_register_commands(QmpCommandList *cmds) { ''', c_prefix=c_name(prefix, protect=False))
@@ -270,7 +270,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor): def visit_end(self): (genc, genh) = self._module[self._main_module] genh.add(mcgen(''' -void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds); +void %(c_prefix)sqmp_register_commands(QmpCommandList *cmds); ''', c_prefix=c_name(self._prefix, protect=False))) genc.add(gen_registry(self._regy.get_content(), self._prefix))
monitor.c +1 -1
@@ -1182,7 +1182,7 @@ static void monitor_init_qmp_commands(void)*/ QTAILQ_INIT (&qmp_commands); -qmp_init_marshal (&qmp_commands); +qmp_register_commands (&qmp_commands);qmp_register_command (&qmp_commands,"query-qmp-schema" , qmp_query_qmp_schema,QCO_ALLOW_PRECONFIG );
qga/main.c +1 -1
@@ -1487,7 +1487,7 @@ int main(int argc, char **argv) config->log_level =G_LOG_LEVEL_ERROR |G_LOG_LEVEL_CRITICAL ;QTAILQ_INIT (&ga_commands); -qga_qmp_init_marshal (&ga_commands); +qga_qmp_register_commands (&ga_commands);init_dfl_pathnames ();config_load (config);
tests/test-qmp-cmds.c +1 -1
@@ -326,7 +326,7 @@ int main(int argc, char **argv)g_test_add_func ("/qmp/dealloc_partial" , test_dealloc_partial);QTAILQ_INIT (&qmp_commands); -test_qmp_init_marshal (&qmp_commands); +test_qmp_register_commands (&qmp_commands);g_test_run ();return 0 ;
docs/devel/qapi-code-gen.txt +2 -2
@@ -1271,7 +1271,7 @@ Example: UserDefOne *qmp_my_command(UserDefOneList *arg1, Error **errp); void qmp_marshal_my_command(QDict *args, QObject **ret, Error **errp); - void example_qmp_init_marshal(QmpCommandList *cmds); + void example_qmp_register_commands(QmpCommandList *cmds); #endif /* EXAMPLE_QAPI_COMMANDS_H */ $ cat qapi-generated/example-qapi-commands.c
@@ -1332,7 +1332,7 @@ Example: visit_free(v); } - void example_qmp_init_marshal(QmpCommandList *cmds) + void example_qmp_register_commands(QmpCommandList *cmds) { qmp_register_command(cmds, "my-command", qmp_marshal_my_command, QCO_NO_OPTIONS);
Signature · 1 line
2.20.0
PATCH 4/13 RFC: qapi: learn to split the schema by 'top-unit'
In reply to Marc-André LureauA module can declare belonging to a 'top-unit', with the corresponding pragma value (the default 'top-unit' is None).
The generators have a chance to break the generated output by units (top-units are visited first). Generated types, visitors, events and commands are split by 'top-unit'. Generated introspection and documentation remain monolithic.
In the following commits, a 'target' unit is introduced. The generated 'target' files will be allowed to used poisoned defines for conditional compilation, since they will be built with the target objects.
TODO: if this approach is acceptable, split the patch, write tests & doc.
Note: I don't really have better ideas, but open for suggestions...
--- scripts/qapi/commands.py | 22 +++++--- scripts/qapi/common.py | 105 +++++++++++++++++++++++++++++++-------- scripts/qapi/events.py | 37 ++++++++------ scripts/qapi/types.py | 8 +-- scripts/qapi/visit.py | 8 +-- 5 files changed, 130 insertions(+), 50 deletions(-)
scripts/qapi/commands.py +14 -8
@@ -237,14 +237,20 @@ class QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor): QAPISchemaModularCVisitor.__init__( self, prefix, 'qapi-commands', ' * Schema-defined QAPI/QMP commands', __doc__) + + def visit_unit_begin(self, unit): + super(self.__class__, self).visit_unit_begin(unit) self._regy = QAPIGenCCode() self._visited_ret_types = {} - def _begin_module(self, name): + def _begin_module(self, name, main_module): self._visited_ret_types[self._genc] = set() - commands = self._module_basename('qapi-commands', name) - types = self._module_basename('qapi-types', name) - visit = self._module_basename('qapi-visit', name) + commands = self._module_basename('qapi-commands', name, + self._unit, main_module) + types = self._module_basename('qapi-types', name, + self._unit, main_module) + visit = self._module_basename('qapi-visit', name, + self._unit, main_module) self._genc.add(mcgen(''' #include "qemu/osdep.h" #include "qemu-common.h"
@@ -267,13 +273,13 @@ class QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor): ''', types=types)) - def visit_end(self): - (genc, genh) = self._module[self._main_module] + def visit_unit_end(self): + (genc, genh) = self.get_module_gen(self._main_module) genh.add(mcgen(''' void %(c_prefix)sqmp_register_commands(QmpCommandList *cmds); ''', - c_prefix=c_name(self._prefix, protect=False))) - genc.add(gen_registry(self._regy.get_content(), self._prefix)) + c_prefix=c_name(self._prefix_unit(), protect=False))) + genc.add(gen_registry(self._regy.get_content(), self._prefix_unit())) def visit_command(self, name, info, ifcond, arg_type, ret_type, gen, success_response, boxed, allow_oob, allow_preconfig):
scripts/qapi/common.py +83 -22
204 lines not on this page · raw message
scripts/qapi/events.py +23 -14
@@ -58,7 +58,12 @@ def gen_param_var(typ): return ret -def gen_event_send(name, arg_type, boxed, event_enum_name): +def gen_event_send(unit, name, arg_type, boxed, event_enum_name): + if not unit: + unit = '' + else: + unit += '_' + # 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
@@ -86,7 +91,7 @@ def gen_event_send(name, arg_type, boxed, event_enum_name): ret += mcgen(''' - emit = qmp_event_get_func_emit(); + emit = %(unit)sqmp_event_get_func_emit(); if (!emit) { return; }
@@ -94,7 +99,7 @@ def gen_event_send(name, arg_type, boxed, event_enum_name): qmp = qmp_event_build_dict("%(name)s"); ''', - name=name) + name=name, unit=unit) if arg_type and not arg_type.is_empty(): ret += mcgen('''
@@ -143,12 +148,17 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor): QAPISchemaModularCVisitor.__init__( self, prefix, 'qapi-events', ' * Schema-defined QAPI/QMP events', __doc__) - self._event_enum_name = c_name(prefix + 'QAPIEvent', protect=False) + + def visit_unit_begin(self, unit): + super(self.__class__, self).visit_unit_begin(unit) + self._event_enum_name = c_name(self._prefix_unit() + 'QAPIEvent', protect=False) self._event_enum_members = [] - def _begin_module(self, name): - types = self._module_basename('qapi-types', name) - visit = self._module_basename('qapi-visit', name) + def _begin_module(self, name, main_module): + types = self._module_basename('qapi-types', name, + self._unit, main_module) + visit = self._module_basename('qapi-visit', name, + self._unit, main_module) self._genc.add(mcgen(''' #include "qemu/osdep.h" #include "qemu-common.h"
@@ -160,7 +170,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor): #include "qapi/qmp-event.h" ''', - visit=visit, prefix=self._prefix)) + visit=visit, prefix=self._prefix_unit())) self._genh.add(mcgen(''' #include "qapi/util.h" #include "%(types)s.h"
@@ -168,17 +178,16 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor): ''', types=types)) - def visit_end(self): - (genc, genh) = self._module[self._main_module] + def visit_unit_end(self): + (genc, genh) = self.get_module_gen(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)) + genc.add(gen_enum_lookup(self._event_enum_name, self._event_enum_members)) 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._genc.add(gen_event_send(self._unit, name, + arg_type, boxed, self._event_enum_name)) self._event_enum_members.append(QAPISchemaMember(name, ifcond))
scripts/qapi/types.py +5 -3
@@ -194,9 +194,11 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor): #include "qapi/util.h" ''')) - def _begin_module(self, name): - types = self._module_basename('qapi-types', name) - visit = self._module_basename('qapi-visit', name) + def _begin_module(self, name, main_module): + types = self._module_basename('qapi-types', name, + self._unit, main_module) + visit = self._module_basename('qapi-visit', name, + self._unit, main_module) self._genc.preamble_add(mcgen(''' #include "qemu/osdep.h" #include "qapi/dealloc-visitor.h"
scripts/qapi/visit.py +5 -3
@@ -298,9 +298,11 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor): ''', prefix=prefix)) - def _begin_module(self, name): - types = self._module_basename('qapi-types', name) - visit = self._module_basename('qapi-visit', name) + def _begin_module(self, name, main_module): + types = self._module_basename('qapi-types', name, + self._unit, main_module) + visit = self._module_basename('qapi-visit', name, + self._unit, main_module) self._genc.preamble_add(mcgen(''' #include "qemu/osdep.h" #include "qemu-common.h"
Signature · 1 line
2.20.0
PATCH 5/13 qapi: add a top-unit 'target' schema
In reply to Marc-André LureauAdd a 'target' top-unit to be compiled seperately from the common qapi modules. This will allow poisoned target #ifdef usage.
The generated commands must be registered seperately.
The events have a different enum, and must thus use a different emitter/limiter.
The DUMMY event is there to force the visit of target, ensuring files are built. It is removed in next commit.
--- qapi/qapi-schema.json | 1 + qapi/target.json | 13 +++ include/qapi/qmp-event.h | 4 + monitor.c | 216 ++++++++++++++++++++++++++------------- qapi/qmp-event.c | 11 ++ Makefile | 7 +- Makefile.target | 2 + 7 files changed, 181 insertions(+), 73 deletions(-) create mode 100644 qapi/target.json
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 +## + +{ 'pragma': { 'top-unit': 'target' } } + +## +# @DUMMY: +## +{ 'event': 'DUMMY' }
include/qapi/qmp-event.h +4 -0
@@ -20,5 +20,9 @@ void qmp_event_set_func_emit(QMPEventFuncEmit emit);QMPEventFuncEmit qmp_event_get_func_emit (void ); +void target_qmp_event_set_func_emit (QMPEventFuncEmit emit); + +QMPEventFuncEmit target_qmp_event_get_func_emit (void ); +QDict *qmp_event_build_dict (const char *event_name);#endif
monitor.c +144 -72
361 lines not on this page · raw message
qapi/qmp-event.c +11 -0
@@ -20,6 +20,7 @@#include "qapi/qmp/qjson.h" static QMPEventFuncEmit qmp_emit; +static QMPEventFuncEmit target_qmp_emit;void qmp_event_set_func_emit (QMPEventFuncEmit emit) {
@@ -31,6 +32,16 @@ QMPEventFuncEmit qmp_event_get_func_emit(void)return qmp_emit; } +void target_qmp_event_set_func_emit (QMPEventFuncEmit emit) +{ + target_qmp_emit = emit; +} + +QMPEventFuncEmit target_qmp_event_get_func_emit (void ) +{ +return target_qmp_emit; +} +static void timestamp_put (QDict *qdict) {int err;
Makefile +6 -1
@@ -92,16 +92,20 @@ GENERATED_FILES = qemu-version.h config-host.h qemu-options.def #see Makefile.objs for the definition of QAPI_MODULES GENERATED_QAPI_FILES = qapi/qapi-builtin-types.h qapi/qapi-builtin-types.c GENERATED_QAPI_FILES += qapi/qapi-types.h qapi/qapi-types.c +GENERATED_QAPI_FILES += qapi/target-qapi-types.h qapi/target-qapi-types.c GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-types-%.h) GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-types-%.c) GENERATED_QAPI_FILES += qapi/qapi-builtin-visit.h qapi/qapi-builtin-visit.c GENERATED_QAPI_FILES += qapi/qapi-visit.h qapi/qapi-visit.c +GENERATED_QAPI_FILES += qapi/target-qapi-visit.h qapi/target-qapi-visit.c GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.h) GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.c) GENERATED_QAPI_FILES += qapi/qapi-commands.h qapi/qapi-commands.c +GENERATED_QAPI_FILES += qapi/target-qapi-commands.h qapi/target-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.h qapi/qapi-events.c +GENERATED_QAPI_FILES += qapi/target-qapi-events.h qapi/target-qapi-events.c GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.h) GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.c) GENERATED_QAPI_FILES += qapi/qapi-introspect.c qapi/qapi-introspect.h
@@ -528,7 +532,8 @@ qga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(qapi-p @>$@ qapi-modules = $(SRC_PATH)/qapi/qapi-schema.json \ - $(QAPI_MODULES:%=$(SRC_PATH)/qapi/%.json) + $(QAPI_MODULES:%=$(SRC_PATH)/qapi/%.json) \ + $(SRC_PATH)/qapi/target.json $(GENERATED_QAPI_FILES): qapi-gen-timestamp ; qapi-gen-timestamp: $(qapi-modules) $(qapi-py)
Makefile.target +2 -0
@@ -156,6 +156,8 @@ endif GENERATED_FILES += hmp-commands.h hmp-commands-info.h +obj-y += qapi/target-qapi-types.o qapi/target-qapi-visit.o +obj-y += qapi/target-qapi-events.o qapi/target-qapi-commands.o obj-y += qapi/qapi-introspect.o endif # CONFIG_SOFTMMU
Signature · 1 line
2.20.0
PATCH 6/13 qapi: make rtc-reset-reinjection and SEV depend on TARGET_I386
In reply to Marc-André LureauMove rtc-reset-reinjection and SEV in target.json and make them conditional on TARGET_I386.
--- qapi/misc.json | 166 -------------------------------------- qapi/target.json | 175 ++++++++++++++++++++++++++++++++++++++++- target/i386/sev_i386.h | 2 +- hw/timer/mc146818rtc.c | 2 +- monitor.c | 31 -------- 5 files changed, 175 insertions(+), 201 deletions(-)
qapi/misc.json +0 -166
@@ -3053,24 +3053,6 @@ { 'event': 'ACPI_DEVICE_OST', 'data': { 'info': 'ACPIOSTInfo' } } -## -# @rtc-reset-reinjection: -# -# This command will reset the RTC interrupt reinjection backlog. -# Can be used if another mechanism to synchronize guest time -# is in effect, for example QEMU guest agent's guest-set-time -# command. -# -# Since: 2.1 -# -# Example: -# -# -> { "execute": "rtc-reset-reinjection" } -# <- { "return": {} } -# -## -{ 'command': 'rtc-reset-reinjection' } - ## # @RTC_CHANGE: #
@@ -3299,154 +3281,6 @@ ## { 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' } - -## -# @SevState: -# -# An enumeration of SEV state information used during @query-sev. -# -# @uninit: The guest is uninitialized. -# -# @launch-update: The guest is currently being launched; plaintext data and -# register state is being imported. -# -# @launch-secret: The guest is currently being launched; ciphertext data -# is being imported. -# -# @running: The guest is fully launched or migrated in. -# -# @send-update: The guest is currently being migrated out to another machine. -# -# @receive-update: The guest is currently being migrated from another machine. -# -# Since: 2.12 -## -{ 'enum': 'SevState', - 'data': ['uninit', 'launch-update', 'launch-secret', 'running', - 'send-update', 'receive-update' ] } - -## -# @SevInfo: -# -# Information about Secure Encrypted Virtualization (SEV) support -# -# @enabled: true if SEV is active -# -# @api-major: SEV API major version -# -# @api-minor: SEV API minor version -# -# @build-id: SEV FW build id -# -# @policy: SEV policy value -# -# @state: SEV guest state -# -# @handle: SEV firmware handle -# -# Since: 2.12 -## -{ 'struct': 'SevInfo', - 'data': { 'enabled': 'bool', - 'api-major': 'uint8', - 'api-minor' : 'uint8', - 'build-id' : 'uint8', - 'policy' : 'uint32', - 'state' : 'SevState', - 'handle' : 'uint32' - } -} - -## -# @query-sev: -# -# Returns information about SEV -# -# Returns: @SevInfo -# -# Since: 2.12 -# -# Example: -# -# -> { "execute": "query-sev" } -# <- { "return": { "enabled": true, "api-major" : 0, "api-minor" : 0, -# "build-id" : 0, "policy" : 0, "state" : "running", -# "handle" : 1 } } -# -## -{ 'command': 'query-sev', 'returns': 'SevInfo' } - -## -# @SevLaunchMeasureInfo: -# -# SEV Guest Launch measurement information -# -# @data: the measurement value encoded in base64 -# -# Since: 2.12 -# -## -{ 'struct': 'SevLaunchMeasureInfo', 'data': {'data': 'str'} } - -## -# @query-sev-launch-measure: -# -# Query the SEV guest launch information. -# -# Returns: The @SevLaunchMeasureInfo for the guest -# -# Since: 2.12 -# -# Example: -# -# -> { "execute": "query-sev-launch-measure" } -# <- { "return": { "data": "4l8LXeNlSPUDlXPJG5966/8%YZ" } } -# -## -{ 'command': 'query-sev-launch-measure', 'returns': 'SevLaunchMeasureInfo' } - -## -# @SevCapability: -# -# The struct describes capability for a Secure Encrypted Virtualization -# feature. -# -# @pdh: Platform Diffie-Hellman key (base64 encoded) -# -# @cert-chain: PDH certificate chain (base64 encoded) -# -# @cbitpos: C-bit location in page table entry -# -# @reduced-phys-bits: Number of physical Address bit reduction when SEV is -# enabled -# -# Since: 2.12 -## -{ 'struct': 'SevCapability', - 'data': { 'pdh': 'str', - 'cert-chain': 'str', - 'cbitpos': 'int', - 'reduced-phys-bits': 'int'} } - -## -# @query-sev-capabilities: -# -# This command is used to get the SEV capabilities, and is supported on AMD -# X86 platforms only. -# -# Returns: SevCapability objects. -# -# Since: 2.12 -# -# Example: -# -# -> { "execute": "query-sev-capabilities" } -# <- { "return": { "pdh": "8CCDD8DDD", "cert-chain": "888CCCDDDEE", -# "cbitpos": 47, "reduced-phys-bits": 5}} -# -## -{ 'command': 'query-sev-capabilities', 'returns': 'SevCapability' } - ## # @set-numa-node: #
qapi/target.json +173 -2
179 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/target-qapi-commands.h" #define SEV_POLICY_NODBG 0x1#define SEV_POLICY_NOKS 0x2
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/target-qapi-commands.h" #include "qapi/qapi-events-misc.h" #include "qapi/visitor.h" #include "exec/address-spaces.h"
monitor.c +0 -31
@@ -1218,12 +1218,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
@@ -4740,31 +4734,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) {
Signature · 1 line
2.20.0
PATCH 7/13 qapi: make s390 commands depend on TARGET_S390X
In reply to Marc-André Lureau--- qapi/misc.json | 137 ----------------------- qapi/target.json | 142 ++++++++++++++++++++++++ include/sysemu/arch_init.h | 7 -- hw/s390x/s390-skeys.c | 2 +- monitor.c | 14 --- qmp.c | 14 --- stubs/arch-query-cpu-model-baseline.c | 13 --- stubs/arch-query-cpu-model-comparison.c | 13 --- target/s390x/cpu_models.c | 5 +- stubs/Makefile.objs | 2 - 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
qapi/misc.json +0 -137
@@ -1865,27 +1865,6 @@ { 'command': 'query-dump-guest-memory-capability', 'returns': 'DumpGuestMemoryCapability' } -## -# @dump-skeys: -# -# Dump guest's storage keys -# -# @filename: the path to the file to dump to -# -# This command is only supported on s390 architecture. -# -# Since: 2.5 -# -# Example: -# -# -> { "execute": "dump-skeys", -# "arguments": { "filename": "/tmp/skeys" } } -# <- { "return": {} } -# -## -{ 'command': 'dump-skeys', - 'data': { 'filename': 'str' } } - ## # @object-add: #
@@ -2228,122 +2207,6 @@ { 'enum': 'CpuModelCompareResult', 'data': [ 'incompatible', 'identical', 'superset', 'subset' ] } -## -# @CpuModelCompareInfo: -# -# The result of a CPU model comparison. -# -# @result: The result of the compare operation. -# @responsible-properties: List of properties that led to the comparison result -# not being identical. -# -# @responsible-properties is a list of QOM property names that led to -# both CPUs not being detected as identical. For identical models, this -# list is empty. -# If a QOM property is read-only, that means there's no known way to make the -# CPU models identical. If the special property name "type" is included, the -# models are by definition not identical and cannot be made identical. -# -# Since: 2.8.0 -## -{ 'struct': 'CpuModelCompareInfo', - 'data': {'result': 'CpuModelCompareResult', - 'responsible-properties': ['str'] - } -} - -## -# @query-cpu-model-comparison: -# -# Compares two CPU models, returning how they compare in a specific -# configuration. The results indicates how both models compare regarding -# runnability. This result can be used by tooling to make decisions if a -# certain CPU model will run in a certain configuration or if a compatible -# CPU model has to be created by baselining. -# -# Usually, a CPU model is compared against the maximum possible CPU model -# of a certain configuration (e.g. the "host" model for KVM). If that CPU -# model is identical or a subset, it will run in that configuration. -# -# The result returned by this command may be affected by: -# -# * QEMU version: CPU models may look different depending on the QEMU version. -# (Except for CPU models reported as "static" in query-cpu-definitions.) -# * machine-type: CPU model may look different depending on the machine-type. -# (Except for CPU models reported as "static" in query-cpu-definitions.) -# * machine options (including accelerator): in some architectures, CPU models -# may look different depending on machine and accelerator options. (Except for -# CPU models reported as "static" in query-cpu-definitions.) -# * "-cpu" arguments and global properties: arguments to the -cpu option and -# global properties may affect expansion of CPU models. Using -# query-cpu-model-expansion while using these is not advised. -# -# Some architectures may not support comparing CPU models. s390x supports -# comparing CPU models. -# -# Returns: a CpuModelBaselineInfo. Returns an error if comparing CPU models is -# not supported, if a model cannot be used, if a model contains -# an unknown cpu definition name, unknown properties or properties -# with wrong types. -# -# Since: 2.8.0 -## -{ 'command': 'query-cpu-model-comparison', - 'data': { 'modela': 'CpuModelInfo', 'modelb': 'CpuModelInfo' }, - 'returns': 'CpuModelCompareInfo' } - -## -# @CpuModelBaselineInfo: -# -# The result of a CPU model baseline. -# -# @model: the baselined CpuModelInfo. -# -# Since: 2.8.0 -## -{ 'struct': 'CpuModelBaselineInfo', - 'data': { 'model': 'CpuModelInfo' } } - -## -# @query-cpu-model-baseline: -# -# Baseline two CPU models, creating a compatible third model. The created -# model will always be a static, migration-safe CPU model (see "static" -# CPU model expansion for details). -# -# This interface can be used by tooling to create a compatible CPU model out -# two CPU models. The created CPU model will be identical to or a subset of -# both CPU models when comparing them. Therefore, the created CPU model is -# guaranteed to run where the given CPU models run. -# -# The result returned by this command may be affected by: -# -# * QEMU version: CPU models may look different depending on the QEMU version. -# (Except for CPU models reported as "static" in query-cpu-definitions.) -# * machine-type: CPU model may look different depending on the machine-type. -# (Except for CPU models reported as "static" in query-cpu-definitions.) -# * machine options (including accelerator): in some architectures, CPU models -# may look different depending on machine and accelerator options. (Except for -# CPU models reported as "static" in query-cpu-definitions.) -# * "-cpu" arguments and global properties: arguments to the -cpu option and -# global properties may affect expansion of CPU models. Using -# query-cpu-model-expansion while using these is not advised. -# -# Some architectures may not support baselining CPU models. s390x supports -# baselining CPU models. -# -# Returns: a CpuModelBaselineInfo. Returns an error if baselining CPU models is -# not supported, if a model cannot be used, if a model contains -# an unknown cpu definition name, unknown properties or properties -# with wrong types. -# -# Since: 2.8.0 -## -{ 'command': 'query-cpu-model-baseline', - 'data': { 'modela': 'CpuModelInfo', - 'modelb': 'CpuModelInfo' }, - 'returns': 'CpuModelBaselineInfo' } - ## # @AddfdInfo: #
qapi/target.json +142 -0
151 lines not on this page · raw message
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
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/target-qapi-commands.h" #include "qapi/qmp/qdict.h" #include "qemu/error-report.h" #include "sysemu/kvm.h"
monitor.c +0 -14
@@ -1218,19 +1218,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" );
@@ -4734,13 +4727,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) {
qmp.c +0 -14
@@ -611,20 +611,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/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/target-qapi-commands.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) {
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
Signature · 1 line
2.20.0
Re: [Qemu-devel] [PATCH 07/13] qapi: make s390 commands depend on TARGET_S390X
Quoted 3 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>Acked-by Cornelia Huck <[email protected]>---
[...]
qapi/target.json line 11
Quoted 10 lines
qapi/target.json +2
-0@@ -7,6 +7,8 @@ { 'pragma': { 'top-unit': 'target' } } +{ 'include': 'misc.json' } +
misc.json is a bit of a kitchen sink. I'd prefer not to include it here, but instead factor out the bits we actually need into a new .json. I suspect that would be an improvement all by itself.
Quoted 3 lines
qapi/target.json +0
-0## # @rtc-reset-reinjection: #
[...]
PATCH 8/13 target.json: add a note about query-cpu* not being s390x-specific
In reply to Marc-André Lureau--- qapi/target.json | 6 ++++++ 1 file changed, 6 insertions(+)
qapi/target.json +6 -0
@@ -277,6 +277,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',
@@ -317,6 +320,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.20.0
PATCH 9/13 qapi: make query-gic-capabilities depend on TARGET_ARM
In reply to Marc-André Lureau--- qapi/misc.json | 43 ------------------------------------------ qapi/target.json | 45 ++++++++++++++++++++++++++++++++++++++++++++ monitor.c | 11 ----------- target/arm/monitor.c | 2 +- 4 files changed, 46 insertions(+), 55 deletions(-)
qapi/misc.json +0 -43
@@ -2978,49 +2978,6 @@ ## { 'command': 'xen-load-devices-state', 'data': {'filename': 'str'} } -## -# @GICCapability: -# -# The struct describes capability for a specific GIC (Generic -# Interrupt Controller) version. These bits are not only decided by -# QEMU/KVM software version, but also decided by the hardware that -# the program is running upon. -# -# @version: version of GIC to be described. Currently, only 2 and 3 -# are supported. -# -# @emulated: whether current QEMU/hardware supports emulated GIC -# device in user space. -# -# @kernel: whether current QEMU/hardware supports hardware -# accelerated GIC device in kernel. -# -# Since: 2.6 -## -{ 'struct': 'GICCapability', - 'data': { 'version': 'int', - 'emulated': 'bool', - 'kernel': 'bool' } } - -## -# @query-gic-capabilities: -# -# This command is ARM-only. It will return a list of GICCapability -# objects that describe its capability bits. -# -# Returns: a list of GICCapability objects. -# -# Since: 2.6 -# -# Example: -# -# -> { "execute": "query-gic-capabilities" } -# <- { "return": [{ "version": 2, "emulated": true, "kernel": false }, -# { "version": 3, "emulated": false, "kernel": true } ] } -# -## -{ 'command': 'query-gic-capabilities', 'returns': ['GICCapability'] } - ## # @CpuInstanceProperties: #
qapi/target.json +45 -0
48 lines not on this page · raw message
monitor.c +0 -11
@@ -1218,9 +1218,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
@@ -4727,14 +4724,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 ());
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/target-qapi-commands.h" static GICCapability *gic_cap_new (int version) {
Signature · 1 line
2.20.0
PATCH 10/13 qapi: make query-cpu-model-expansion depend on s390 or x86
In reply to Marc-André Lureau--- qapi/misc.json | 51 ------------------------- qapi/target.json | 52 ++++++++++++++++++++++++++ include/sysemu/arch_init.h | 3 -- monitor.c | 3 -- qmp.c | 7 ---- stubs/arch-query-cpu-model-expansion.c | 13 ------- target/i386/cpu.c | 3 +- target/s390x/cpu_models.c | 2 +- stubs/Makefile.objs | 1 - 9 files changed, 55 insertions(+), 80 deletions(-) delete mode 100644 stubs/arch-query-cpu-model-expansion.c
qapi/misc.json +0 -51
@@ -2133,57 +2133,6 @@ 'data': [ 'static', 'full' ] } -## -# @CpuModelExpansionInfo: -# -# The result of a cpu model expansion. -# -# @model: the expanded CpuModelInfo. -# -# Since: 2.8.0 -## -{ 'struct': 'CpuModelExpansionInfo', - 'data': { 'model': 'CpuModelInfo' } } - - -## -# @query-cpu-model-expansion: -# -# Expands a given CPU model (or a combination of CPU model + additional options) -# to different granularities, allowing tooling to get an understanding what a -# specific CPU model looks like in QEMU under a certain configuration. -# -# This interface can be used to query the "host" CPU model. -# -# The data returned by this command may be affected by: -# -# * QEMU version: CPU models may look different depending on the QEMU version. -# (Except for CPU models reported as "static" in query-cpu-definitions.) -# * machine-type: CPU model may look different depending on the machine-type. -# (Except for CPU models reported as "static" in query-cpu-definitions.) -# * machine options (including accelerator): in some architectures, CPU models -# may look different depending on machine and accelerator options. (Except for -# CPU models reported as "static" in query-cpu-definitions.) -# * "-cpu" arguments and global properties: arguments to the -cpu option and -# global properties may affect expansion of CPU models. Using -# query-cpu-model-expansion while using these is not advised. -# -# Some architectures may not support all expansion types. s390x supports -# "full" and "static". -# -# Returns: a CpuModelExpansionInfo. Returns an error if expanding CPU models is -# not supported, if the model cannot be expanded, if the model contains -# an unknown CPU definition name, unknown properties or properties -# with a wrong type. Also returns an error if an expansion type is -# not supported. -# -# Since: 2.8.0 -## -{ 'command': 'query-cpu-model-expansion', - 'data': { 'type': 'CpuModelExpansionType', - 'model': 'CpuModelInfo' }, - 'returns': 'CpuModelExpansionInfo' } - ## # @CpuModelCompareResult: #
qapi/target.json +52 -0
55 lines not on this page · raw message
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
@@ -1218,9 +1218,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" );
qmp.c +0 -7
@@ -604,13 +604,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/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 +2 -1
@@ -41,6 +41,7 @@#include "qapi/visitor.h" #include "qom/qom-qobject.h" #include "sysemu/arch_init.h" +#include "qapi/target-qapi-commands.h" #include "standard-headers/asm-x86/kvm_para.h"
@@ -4027,7 +4028,7 @@ out: }CpuModelExpansionInfo * -arch_query_cpu_model_expansion (CpuModelExpansionType type, +qmp_query_cpu_model_expansion (CpuModelExpansionType type,CpuModelInfo *model,Error **errp) {
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) {
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
Signature · 1 line
2.20.0
Re: [Qemu-devel] [PATCH 10/13] qapi: make query-cpu-model-expansion depend on s390 or x86
Quoted 3 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>Reviewed-by Eduardo Habkost <[email protected]>Acked-by Cornelia Huck <[email protected]>
Doesn't build linux-user:
target/i386/cpu.o: In function `qmp_query_cpu_model_expansion':
/work/armbru/qemu/target/i386/cpu.c:4082: undefined reference to `qapi_free_CpuModelExpansionInfo'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:200: qemu-i386] Error 1
target/i386/cpu.o: In function `qmp_query_cpu_model_expansion':
/work/armbru/qemu/target/i386/cpu.c:4082: undefined reference to `qapi_free_CpuModelExpansionInfo'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:200: qemu-x86_64] Error 1
Fixup:
target/i386/cpu.c +2 -0
@@ -3882,6 +3882,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.
@@ -4084,6 +4085,7 @@ out: }return ret; } +#endif /* !CONFIG_USER_ONLY */ static gchar *x86_gdb_arch_name (CPUState *cs) {
PATCH 11/13 qapi: make query-cpu-definitions depend on specific targets
In reply to Marc-André LureauIt depends on TARGET_PPC || TARGET_ARM || TARGET_I386 || TARGET_S390X.
--- qapi/misc.json | 58 ------------------------------ qapi/target.json | 64 +++++++++++++++++++++++++++++++++ include/sysemu/arch_init.h | 1 - monitor.c | 22 ------------ qmp.c | 5 --- stubs/arch-query-cpu-def.c | 11 ------ target/arm/helper.c | 3 +- target/i386/cpu.c | 3 +- target/ppc/translate_init.inc.c | 3 +- target/s390x/cpu_models.c | 2 +- stubs/Makefile.objs | 1 - 11 files changed, 71 insertions(+), 102 deletions(-) delete mode 100644 stubs/arch-query-cpu-def.c
qapi/misc.json +0 -58
@@ -1991,54 +1991,6 @@ ## { 'command': 'query-machines', 'returns': ['MachineInfo'] } -## -# @CpuDefinitionInfo: -# -# Virtual CPU definition. -# -# @name: the name of the CPU definition -# -# @migration-safe: whether a CPU definition can be safely used for -# migration in combination with a QEMU compatibility machine -# when migrating between different QEMU versions and between -# hosts with different sets of (hardware or software) -# capabilities. If not provided, information is not available -# and callers should not assume the CPU definition to be -# migration-safe. (since 2.8) -# -# @static: whether a CPU definition is static and will not change depending on -# QEMU version, machine type, machine options and accelerator options. -# A static model is always migration-safe. (since 2.8) -# -# @unavailable-features: List of properties that prevent -# the CPU model from running in the current -# host. (since 2.8) -# @typename: Type name that can be used as argument to @device-list-properties, -# to introspect properties configurable using -cpu or -global. -# (since 2.9) -# -# @unavailable-features is a list of QOM property names that -# represent CPU model attributes that prevent the CPU from running. -# If the QOM property is read-only, that means there's no known -# way to make the CPU model run in the current host. Implementations -# that choose not to provide specific information return the -# property name "type". -# If the property is read-write, it means that it MAY be possible -# to run the CPU model in the current host if that property is -# changed. Management software can use it as hints to suggest or -# choose an alternative for the user, or just to generate meaningful -# error messages explaining why the CPU model can't be used. -# If @unavailable-features is an empty list, the CPU model is -# runnable using the current host and machine-type. -# If @unavailable-features is not present, runnability -# information for the CPU is not available. -# -# Since: 1.2.0 -## -{ 'struct': 'CpuDefinitionInfo', - 'data': { 'name': 'str', '*migration-safe': 'bool', 'static': 'bool', - '*unavailable-features': [ 'str' ], 'typename': 'str' } } - ## # @MemoryInfo: #
@@ -2071,16 +2023,6 @@ ## { 'command': 'query-memory-size-summary', 'returns': 'MemoryInfo' } -## -# @query-cpu-definitions: -# -# Return a list of supported virtual CPU definitions -# -# Returns: a list of CpuDefInfo -# -# Since: 1.2.0 -## -{ 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] } ## # @CpuModelInfo:
qapi/target.json +64 -0
67 lines not on this page · raw message
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
@@ -1204,26 +1204,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 ) {/*
@@ -1244,8 +1224,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 );
qmp.c +0 -5
@@ -599,11 +599,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/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/target-qapi-commands.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 +2 -1
@@ -36,6 +36,7 @@#include "qapi/error.h" #include "qapi/qapi-visit-misc.h" #include "qapi/qapi-visit-run-state.h" +#include "qapi/target-qapi-commands.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qapi/visitor.h"
@@ -3753,7 +3754,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/target-qapi-commands.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 ,
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
Signature · 1 line
2.20.0
Re: [Qemu-devel] [PATCH 11/13] qapi: make query-cpu-definitions depend on specific targets
Quoted 5 lines · Marc-André Lureau
It depends on
TARGET_PPC||TARGET_ARM||TARGET_I386||TARGET_S390X.Signed-off-by Marc-André Lureau <[email protected]>Reviewed-by Eduardo Habkost <[email protected]>Acked-by Cornelia Huck <[email protected]>
[...]
target/i386/cpu.c line 39
Quoted 9 lines
target/i386/cpu.c +1
-0@@ -36,6 +36,7 @@#include "qapi/error.h" #include "qapi/qapi-visit-misc.h" #include "qapi/qapi-visit-run-state.h" +#include "qapi/target-qapi-commands.h"
You already added this one in the previous patch.
Quoted 3 lines
target/i386/cpu.c +0
-0#include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qapi/visitor.h"
[...]
PATCH 12/13 qapi: remove qmp_unregister_command()
In reply to Marc-André LureauThis 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.20.0
PATCH 13/13 qapi: move RTC_CHANGE to the target schema
In reply to Marc-André LureauA 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.
Note2: The rate limite could perhaps be part of the schema, and the common event emitter code, to simplify the need of custom and #ifdef code in the monitor.
--- qapi/misc.json | 23 ----------------------- qapi/target.json | 23 +++++++++++++++++++++++ hw/ppc/spapr_rtc.c | 2 +- hw/timer/mc146818rtc.c | 2 +- monitor.c | 8 +++++++- 5 files changed, 32 insertions(+), 26 deletions(-)
qapi/misc.json +0 -23
@@ -2807,29 +2807,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
@@ -9,6 +9,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: #
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/target-qapi-events.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/target-qapi-commands.h" -#include "qapi/qapi-events-misc.h" +#include "qapi/target-qapi-events.h" #include "qapi/visitor.h" #include "exec/address-spaces.h"
monitor.c +7 -1
@@ -674,7 +674,6 @@ monitor_qapi_event_queue(unsigned event, QDict *qdict) .size = QAPI_EVENT__MAX, .rate = { /* Limit guest-triggerable events to 1 per second */ - [QAPI_EVENT_RTC_CHANGE] = 1000 * SCALE_MS, [QAPI_EVENT_WATCHDOG] = 1000 * SCALE_MS, [QAPI_EVENT_BALLOON_CHANGE] = 1000 * SCALE_MS, [QAPI_EVENT_QUORUM_REPORT_BAD] = 1000 * SCALE_MS,
@@ -718,6 +717,13 @@ target_monitor_qapi_event_queue(unsigned event, QDict *qdict)static MonitorEventRateLimit limiter = { .size =TARGET_QAPI_EVENT__MAX , .rate = { +/* Limit guest-triggerable events to 1 per second */ +#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 ) + [TARGET_QAPI_EVENT_RTC_CHANGE ] =1000 *SCALE_MS , +#endif [TARGET_QAPI_EVENT__MAX ] =0 , }, };
Signature · 1 line
2.20.0
Quoted 9 lines · Marc-André Lureau
Hi,
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.
Quoted 7 lines
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.
Lovely except for the 'top-unit' feature. I believe the existing modules can do the job. Quoting my "[PATCH v2 00/29] Modularize generated QAPI code":
Related: Marc-André's 'unit' pragma proposal. That's a different way to split off parts of the generated code, motivated by the desire to use poisoned identifiers such as TARGET_I386. I noted in my review of v3 that I "can either accept it, or come up with a better solution." This is my attempt at a better solution. It's a bit more ambitious, and thus more useful (I hope). The pragma has one theoretical advantage, though: you can modularize the generated output in different ways than the input. The patches using don't do that, however.
I'm going to post RFC patches that show how to do a target-dependent module. Then we can discuss the two approaches.