Now that we have per target implementations of this function, we simply dispatch the call to relevant implementation. This eliminates duplication of qmp_query_cpu_definitions symbol.
We need to define individual stubs for targets function since each existing binary only has one variant defined. Stub mechanism works per compilation unit, thus we need one file per symbol. Acked-by: Markus Armbruster <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]> Link: https://lore.kernel.org/qemu-devel/[email protected] Signed-off-by: Pierrick Bouvier <[email protected]> --- hw/core/machine-qmp-cmds.c | 32 +++++++++++++++++++++++++++ stubs/meson.build | 6 +++++ stubs/qmp-cpu-arm.c | 9 ++++++++ stubs/qmp-cpu-i386.c | 9 ++++++++ stubs/qmp-cpu-loongarch.c | 9 ++++++++ stubs/qmp-cpu-mips.c | 9 ++++++++ stubs/qmp-cpu-ppc.c | 9 ++++++++ stubs/qmp-cpu-riscv.c | 9 ++++++++ stubs/qmp-cpu-s390x.c | 6 +++++ stubs/qmp-cpu.c | 7 ------ target/arm/arm-qmp-cmds.c | 5 ----- target/i386/cpu.c | 5 ----- target/loongarch/loongarch-qmp-cmds.c | 5 ----- target/mips/system/mips-qmp-cmds.c | 5 ----- target/ppc/ppc-qmp-cmds.c | 5 ----- target/riscv/riscv-qmp-cmds.c | 5 ----- target/s390x/cpu_models_system.c | 5 ----- 17 files changed, 98 insertions(+), 42 deletions(-) create mode 100644 stubs/qmp-cpu-arm.c create mode 100644 stubs/qmp-cpu-i386.c create mode 100644 stubs/qmp-cpu-loongarch.c create mode 100644 stubs/qmp-cpu-mips.c create mode 100644 stubs/qmp-cpu-ppc.c create mode 100644 stubs/qmp-cpu-riscv.c diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index 9c08b17510a..3fee45d568d 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -27,6 +27,7 @@ #include "system/hostmem.h" #include "system/hw_accel.h" #include "system/numa.h" +#include "system/qmp-cpu.h" #include "system/ramlist.h" #include "system/runstate.h" #include "system/system.h" @@ -93,6 +94,37 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp) return head; } +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +{ + switch (target_arch()) { + case SYS_EMU_TARGET_AARCH64: + case SYS_EMU_TARGET_ARM: + return qmp_query_arm_cpu_definitions(errp); + case SYS_EMU_TARGET_I386: + case SYS_EMU_TARGET_X86_64: + return qmp_query_i386_cpu_definitions(errp); + case SYS_EMU_TARGET_LOONGARCH64: + return qmp_query_loongarch_cpu_definitions(errp); + case SYS_EMU_TARGET_MIPS: + case SYS_EMU_TARGET_MIPS64: + case SYS_EMU_TARGET_MIPS64EL: + case SYS_EMU_TARGET_MIPSEL: + return qmp_query_mips_cpu_definitions(errp); + case SYS_EMU_TARGET_PPC: + case SYS_EMU_TARGET_PPC64: + return qmp_query_ppc_cpu_definitions(errp); + case SYS_EMU_TARGET_RISCV32: + case SYS_EMU_TARGET_RISCV64: + return qmp_query_riscv_cpu_definitions(errp); + case SYS_EMU_TARGET_S390X: + return qmp_query_s390x_cpu_definitions(errp); + default: + error_setg(errp, + "CPU model definitions are not supported on this target"); + return NULL; + } +} + MachineInfoList *qmp_query_machines(bool has_compat_props, bool compat_props, Error **errp) { diff --git a/stubs/meson.build b/stubs/meson.build index 29b6644b254..dcb67ce5295 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -86,6 +86,12 @@ if have_system stub_ss.add(files('qmp-i386-sgx.c')) stub_ss.add(files('qmp-i386-xen.c')) stub_ss.add(files('qmp-cpu.c')) + stub_ss.add(files('qmp-cpu-arm.c')) + stub_ss.add(files('qmp-cpu-i386.c')) + stub_ss.add(files('qmp-cpu-loongarch.c')) + stub_ss.add(files('qmp-cpu-mips.c')) + stub_ss.add(files('qmp-cpu-ppc.c')) + stub_ss.add(files('qmp-cpu-riscv.c')) stub_ss.add(files('qmp-cpu-s390x.c')) stub_ss.add(files('qmp-cpu-s390x-kvm.c')) if have_hmp diff --git a/stubs/qmp-cpu-arm.c b/stubs/qmp-cpu-arm.c new file mode 100644 index 00000000000..6249d7bde8d --- /dev/null +++ b/stubs/qmp-cpu-arm.c @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "system/qmp-cpu.h" + +CpuDefinitionInfoList *qmp_query_arm_cpu_definitions(Error **errp) +{ + g_assert_not_reached(); +} diff --git a/stubs/qmp-cpu-i386.c b/stubs/qmp-cpu-i386.c new file mode 100644 index 00000000000..4858951f8c2 --- /dev/null +++ b/stubs/qmp-cpu-i386.c @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "system/qmp-cpu.h" + +CpuDefinitionInfoList *qmp_query_i386_cpu_definitions(Error **errp) +{ + g_assert_not_reached(); +} diff --git a/stubs/qmp-cpu-loongarch.c b/stubs/qmp-cpu-loongarch.c new file mode 100644 index 00000000000..695b6558d7e --- /dev/null +++ b/stubs/qmp-cpu-loongarch.c @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "system/qmp-cpu.h" + +CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions(Error **errp) +{ + g_assert_not_reached(); +} diff --git a/stubs/qmp-cpu-mips.c b/stubs/qmp-cpu-mips.c new file mode 100644 index 00000000000..4d251d5f078 --- /dev/null +++ b/stubs/qmp-cpu-mips.c @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "system/qmp-cpu.h" + +CpuDefinitionInfoList *qmp_query_mips_cpu_definitions(Error **errp) +{ + g_assert_not_reached(); +} diff --git a/stubs/qmp-cpu-ppc.c b/stubs/qmp-cpu-ppc.c new file mode 100644 index 00000000000..315461c7db7 --- /dev/null +++ b/stubs/qmp-cpu-ppc.c @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "system/qmp-cpu.h" + +CpuDefinitionInfoList *qmp_query_ppc_cpu_definitions(Error **errp) +{ + g_assert_not_reached(); +} diff --git a/stubs/qmp-cpu-riscv.c b/stubs/qmp-cpu-riscv.c new file mode 100644 index 00000000000..ce500ffa3f3 --- /dev/null +++ b/stubs/qmp-cpu-riscv.c @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "system/qmp-cpu.h" + +CpuDefinitionInfoList *qmp_query_riscv_cpu_definitions(Error **errp) +{ + g_assert_not_reached(); +} diff --git a/stubs/qmp-cpu-s390x.c b/stubs/qmp-cpu-s390x.c index 71e794482b5..4556072a226 100644 --- a/stubs/qmp-cpu-s390x.c +++ b/stubs/qmp-cpu-s390x.c @@ -3,6 +3,12 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qapi/qapi-commands-machine.h" +#include "system/qmp-cpu.h" + +CpuDefinitionInfoList *qmp_query_s390x_cpu_definitions(Error **errp) +{ + g_assert_not_reached(); +} CpuModelCompareInfo * qmp_query_cpu_model_comparison(CpuModelInfo *infoa, diff --git a/stubs/qmp-cpu.c b/stubs/qmp-cpu.c index a8c7ee89b9d..ac185f09f2d 100644 --- a/stubs/qmp-cpu.c +++ b/stubs/qmp-cpu.c @@ -12,10 +12,3 @@ qmp_query_cpu_model_expansion(CpuModelExpansionType type, error_setg(errp, "CPU model expansion is not supported on this target"); return NULL; } - -CpuDefinitionInfoList * -qmp_query_cpu_definitions(Error **errp) -{ - error_setg(errp, "CPU model definitions are not supported on this target"); - return NULL; -} diff --git a/target/arm/arm-qmp-cmds.c b/target/arm/arm-qmp-cmds.c index d227a06e2c6..cef0c27db65 100644 --- a/target/arm/arm-qmp-cmds.c +++ b/target/arm/arm-qmp-cmds.c @@ -228,8 +228,3 @@ CpuDefinitionInfoList *qmp_query_arm_cpu_definitions(Error **errp) return cpu_list; } - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - return qmp_query_arm_cpu_definitions(errp); -} diff --git a/target/i386/cpu.c b/target/i386/cpu.c index dc762b802e1..5da80ade70e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -8201,11 +8201,6 @@ CpuDefinitionInfoList *qmp_query_i386_cpu_definitions(Error **errp) return cpu_list; } -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - return qmp_query_i386_cpu_definitions(errp); -} - #endif /* !CONFIG_USER_ONLY */ static uint8_t x86_cpu_get_host_avx10_version(void) diff --git a/target/loongarch/loongarch-qmp-cmds.c b/target/loongarch/loongarch-qmp-cmds.c index dadf5de889d..351b6aed7c8 100644 --- a/target/loongarch/loongarch-qmp-cmds.c +++ b/target/loongarch/loongarch-qmp-cmds.c @@ -41,11 +41,6 @@ CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions(Error **errp) return cpu_list; } -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - return qmp_query_loongarch_cpu_definitions(errp); -} - static const char *cpu_model_advertised_features[] = { "lsx", "lasx", "lbt", "pmu", "kvm-pv-ipi", "kvm-steal-time", "msgint", "ptw", NULL diff --git a/target/mips/system/mips-qmp-cmds.c b/target/mips/system/mips-qmp-cmds.c index 560c7915365..ccbdbf8877a 100644 --- a/target/mips/system/mips-qmp-cmds.c +++ b/target/mips/system/mips-qmp-cmds.c @@ -48,8 +48,3 @@ CpuDefinitionInfoList *qmp_query_mips_cpu_definitions(Error **errp) return cpu_list; } - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - return qmp_query_mips_cpu_definitions(errp); -} diff --git a/target/ppc/ppc-qmp-cmds.c b/target/ppc/ppc-qmp-cmds.c index fe35ae1ac04..1338233ee63 100644 --- a/target/ppc/ppc-qmp-cmds.c +++ b/target/ppc/ppc-qmp-cmds.c @@ -83,8 +83,3 @@ CpuDefinitionInfoList *qmp_query_ppc_cpu_definitions(Error **errp) return cpu_list; } - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - return qmp_query_ppc_cpu_definitions(errp); -} diff --git a/target/riscv/riscv-qmp-cmds.c b/target/riscv/riscv-qmp-cmds.c index ccd6ae1d5cf..b70975affed 100644 --- a/target/riscv/riscv-qmp-cmds.c +++ b/target/riscv/riscv-qmp-cmds.c @@ -66,11 +66,6 @@ CpuDefinitionInfoList *qmp_query_riscv_cpu_definitions(Error **errp) return cpu_list; } -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - return qmp_query_riscv_cpu_definitions(errp); -} - static void riscv_check_if_cpu_available(RISCVCPU *cpu, Error **errp) { if (!riscv_cpu_accelerator_compatible(cpu)) { diff --git a/target/s390x/cpu_models_system.c b/target/s390x/cpu_models_system.c index f963ca5248a..f82b693b0cd 100644 --- a/target/s390x/cpu_models_system.c +++ b/target/s390x/cpu_models_system.c @@ -97,11 +97,6 @@ CpuDefinitionInfoList *qmp_query_s390x_cpu_definitions(Error **errp) return list_data.list; } -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - return qmp_query_s390x_cpu_definitions(errp); -} - static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, const char *info_arg_name, Error **errp) { -- 2.43.0
