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. Add a stub to satisfy linking in user-mode: /usr/bin/ld: libqemu-i386-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_get_feature_words': target/i386/cpu.c:4643: undefined reference to `visit_type_X86CPUFeatureWordInfoList' collect2: error: ld returned 1 exit status make: *** [Makefile.ninja:1125: qemu-i386] Error 1 Acked-by: Richard Henderson <richard.hender...@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <phi...@redhat.com> --- v3: Reworded + Meson rebase --- qapi/machine-target.json | 45 ++++++++++++++++++++++++++++++++++++++ qapi/machine.json | 42 ----------------------------------- target/i386/cpu.c | 2 +- target/i386/feature-stub.c | 23 +++++++++++++++++++ target/i386/meson.build | 1 + 5 files changed, 70 insertions(+), 43 deletions(-) create mode 100644 target/i386/feature-stub.c diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 698850cc78..b4d769a53b 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -4,6 +4,51 @@ # This work is licensed under the terms of the GNU GPL, version 2 or later. # See the COPYING file in the top-level directory. +## +# @X86CPURegister32: +# +# A X86 32-bit register +# +# Since: 1.5 +## +{ 'enum': 'X86CPURegister32', + 'data': [ 'EAX', 'EBX', 'ECX', 'EDX', 'ESP', 'EBP', 'ESI', 'EDI' ], + 'if': 'defined(TARGET_I386)' } + +## +# @X86CPUFeatureWordInfo: +# +# Information about a X86 CPU feature word +# +# @cpuid-input-eax: Input EAX value for CPUID instruction for that feature word +# +# @cpuid-input-ecx: Input ECX value for CPUID instruction for that +# feature word +# +# @cpuid-register: Output register containing the feature bits +# +# @features: value of output register, containing the feature bits +# +# Since: 1.5 +## +{ 'struct': 'X86CPUFeatureWordInfo', + 'data': { 'cpuid-input-eax': 'int', + '*cpuid-input-ecx': 'int', + 'cpuid-register': 'X86CPURegister32', + 'features': 'int' }, + 'if': 'defined(TARGET_I386)' } + +## +# @DummyForceArrays: +# +# Not used by QMP; hack to let us use X86CPUFeatureWordInfoList internally +# +# Since: 2.5 +## +{ 'struct': 'DummyForceArrays', + 'data': { 'unused': ['X86CPUFeatureWordInfo'] }, + 'if': 'defined(TARGET_I386)' } + ## # @CpuModelInfo: # diff --git a/qapi/machine.json b/qapi/machine.json index 72f014bb5b..cb878acdac 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -544,48 +544,6 @@ 'dst': 'uint16', 'val': 'uint8' }} -## -# @X86CPURegister32: -# -# A X86 32-bit register -# -# Since: 1.5 -## -{ 'enum': 'X86CPURegister32', - 'data': [ 'EAX', 'EBX', 'ECX', 'EDX', 'ESP', 'EBP', 'ESI', 'EDI' ] } - -## -# @X86CPUFeatureWordInfo: -# -# Information about a X86 CPU feature word -# -# @cpuid-input-eax: Input EAX value for CPUID instruction for that feature word -# -# @cpuid-input-ecx: Input ECX value for CPUID instruction for that -# feature word -# -# @cpuid-register: Output register containing the feature bits -# -# @features: value of output register, containing the feature bits -# -# Since: 1.5 -## -{ 'struct': 'X86CPUFeatureWordInfo', - 'data': { 'cpuid-input-eax': 'int', - '*cpuid-input-ecx': 'int', - 'cpuid-register': 'X86CPURegister32', - 'features': 'int' } } - -## -# @DummyForceArrays: -# -# Not used by QMP; hack to let us use X86CPUFeatureWordInfoList internally -# -# Since: 2.5 -## -{ 'struct': 'DummyForceArrays', - 'data': { 'unused': ['X86CPUFeatureWordInfo'] } } - ## # @NumaCpuOptions: # diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 3ffd877dd5..d45fa217cc 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -38,7 +38,7 @@ #include "qemu/option.h" #include "qemu/config-file.h" #include "qapi/error.h" -#include "qapi/qapi-visit-machine.h" +#include "qapi/qapi-visit-machine-target.h" #include "qapi/qapi-visit-run-state.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" diff --git a/target/i386/feature-stub.c b/target/i386/feature-stub.c new file mode 100644 index 0000000000..787c3c7fa1 --- /dev/null +++ b/target/i386/feature-stub.c @@ -0,0 +1,23 @@ +/* + * QAPI x86 CPU features stub + * + * Copyright (c) 2020 Red Hat, Inc. + * + * Author: + * Philippe Mathieu-Daudé <phi...@redhat.com> + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qapi/qapi-visit-machine-target.h" + +bool visit_type_X86CPUFeatureWordInfoList(Visitor *v, const char *name, + X86CPUFeatureWordInfoList **obj, + Error **errp) +{ + g_assert_not_reached(); +} diff --git a/target/i386/meson.build b/target/i386/meson.build index e0b71ade56..0c5d9e6caf 100644 --- a/target/i386/meson.build +++ b/target/i386/meson.build @@ -5,6 +5,7 @@ i386_ss.add(files( 'helper.c', 'xsave_helper.c', )) +i386_ss.add(when: 'CONFIG_SOFTMMU', if_false: files('feature-stub.c')) i386_ss.add(when: 'CONFIG_TCG', if_true: files( 'bpt_helper.c', 'cc_helper.c', -- 2.26.2