Eduardo Habkost <ehabk...@redhat.com> writes: > On Thu, Oct 01, 2020 at 04:41:52PM +0200, Philippe Mathieu-Daudé wrote: >> Only qemu-system-FOO and qemu-storage-daemon provide QMP >> monitors, therefore such declarations and definitions are >> irrelevant for user-mode emulation. >> >> Restricting the x86-specific commands to machine-target.json >> pulls less QAPI-generated code into user-mode. > > Is this still true without "qapi: Restrict code generated for > user-mode"? > > Markus, Eric: what's the difference between machine.json and > machine-target.json? commit 7f7b4e7abef4 ("qapi: Split > machine-target.json off target.json and misc.json") explains what > but not why.
My bad. Short explanation: machine-target.json can use preprocessor symbols with 'if' that are only available in target-specific code: TARGET_S390X, TARGET_I386, TARGET_ARM, ... This requires compiling per target. machine.json can't use these, because it's compiled just once. Same for misc-target.json and misc.json. Now the long explanation. The clue is buried in the patch: diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs index 01dced01aa..4e87bef6e1 100644 --- a/qapi/Makefile.objs +++ b/qapi/Makefile.objs @@ -9,7 +9,7 @@ QAPI_COMMON_MODULES = audio authz block-core block char common crypto QAPI_COMMON_MODULES += introspect job machine migration misc net QAPI_COMMON_MODULES += qdev qom rdma rocker run-state sockets tpm QAPI_COMMON_MODULES += trace transaction ui -QAPI_TARGET_MODULES = target +QAPI_TARGET_MODULES = machine-target target QAPI_MODULES = $(QAPI_COMMON_MODULES) $(QAPI_TARGET_MODULES) util-obj-y += qapi-builtin-types.o QAPI_TARGET_MODULES appears in commit 61eb9e80d5: qapi: New module target.json We 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. Signed-off-by: Markus Armbruster <arm...@redhat.com> Aha: it's about compiling per target, to make target-specific conditionals available. This part of qapi/Makefile.objs has since morphed into qapi_inputs = [] qapi_specific_outputs = [] foreach module : qapi_all_modules qapi_inputs += [ files(module + '.json') ] qapi_module_outputs = [ ... ] if module.endswith('-target') qapi_specific_outputs += qapi_module_outputs else qapi_util_outputs += qapi_module_outputs endif endforeach in qapi/meson.build. Further down: # Now go through all the outputs and add them to the right sourceset. # These loops must be synchronized with the output of the above custom target. i = 0 foreach output : qapi_util_outputs if output.endswith('.h') genh += qapi_files[i] endif util_ss.add(qapi_files[i]) i = i + 1 endforeach foreach output : qapi_specific_outputs + qapi_nonmodule_outputs if output.endswith('.h') genh += qapi_files[i] endif specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: qapi_files[i]) i = i + 1 endforeach The source files generated for the "common" modules are added to sourceset util_ss, and the ones for the "target" modules are added to sourceset specific_ss. The former gets compiled just once, and the .o get linked into pretty much everything. The latter gets compiled per target, and the .o get linked into target-specific executables. Clear as mud? [...]