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.
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,