Commit 0e1015d295 for qemu.org
commit 0e1015d2959e307fb91637b93339fe7d5ac145fd
Author: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Date: Fri Oct 16 16:25:09 2026 +0000
qmp: reimplement qmp_query_cpu_model_expansion as a dispatcher function
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_model_expansion symbol.
mips and ppc implementations were unsupported, so remove them and let
them be handled by default case of the dispatcher.
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: Yonggang Luo <luoyonggang@gmail.com>
Link: https://lore.kernel.org/qemu-devel/20261016162509.24854-7-pierrick.bouvier@oss.qualcomm.com
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 3fee45d568..07a048d0a9 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -125,6 +125,32 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
}
}
+CpuModelExpansionInfo *
+qmp_query_cpu_model_expansion(CpuModelExpansionType type,
+ CpuModelInfo *model,
+ Error **errp)
+{
+ switch (target_arch()) {
+ case SYS_EMU_TARGET_AARCH64:
+ case SYS_EMU_TARGET_ARM:
+ return qmp_query_arm_cpu_model_expansion(type, model, errp);
+ case SYS_EMU_TARGET_I386:
+ case SYS_EMU_TARGET_X86_64:
+ return qmp_query_i386_cpu_model_expansion(type, model, errp);
+ case SYS_EMU_TARGET_LOONGARCH64:
+ return qmp_query_loongarch_cpu_model_expansion(type, model, errp);
+ case SYS_EMU_TARGET_RISCV32:
+ case SYS_EMU_TARGET_RISCV64:
+ return qmp_query_riscv_cpu_model_expansion(type, model, errp);
+ case SYS_EMU_TARGET_S390X:
+ return qmp_query_s390x_cpu_model_expansion(type, model, errp);
+ default:
+ error_setg(errp,
+ "CPU model expansion is 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 4a26f795a6..744fb759a2 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -84,7 +84,6 @@ if have_system
stub_ss.add(files('qmp-i386-sev.c'))
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'))
diff --git a/stubs/qmp-cpu-arm.c b/stubs/qmp-cpu-arm.c
index 6249d7bde8..0336508ac9 100644
--- a/stubs/qmp-cpu-arm.c
+++ b/stubs/qmp-cpu-arm.c
@@ -7,3 +7,11 @@ CpuDefinitionInfoList *qmp_query_arm_cpu_definitions(Error **errp)
{
g_assert_not_reached();
}
+
+CpuModelExpansionInfo *
+qmp_query_arm_cpu_model_expansion(CpuModelExpansionType type,
+ CpuModelInfo *model,
+ Error **errp)
+{
+ g_assert_not_reached();
+}
diff --git a/stubs/qmp-cpu-i386.c b/stubs/qmp-cpu-i386.c
index 4858951f8c..f8a485c23e 100644
--- a/stubs/qmp-cpu-i386.c
+++ b/stubs/qmp-cpu-i386.c
@@ -7,3 +7,11 @@ CpuDefinitionInfoList *qmp_query_i386_cpu_definitions(Error **errp)
{
g_assert_not_reached();
}
+
+CpuModelExpansionInfo *
+qmp_query_i386_cpu_model_expansion(CpuModelExpansionType type,
+ CpuModelInfo *model,
+ Error **errp)
+{
+ g_assert_not_reached();
+}
diff --git a/stubs/qmp-cpu-loongarch.c b/stubs/qmp-cpu-loongarch.c
index 695b6558d7..42231e816b 100644
--- a/stubs/qmp-cpu-loongarch.c
+++ b/stubs/qmp-cpu-loongarch.c
@@ -7,3 +7,11 @@ CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions(Error **errp)
{
g_assert_not_reached();
}
+
+CpuModelExpansionInfo *
+qmp_query_loongarch_cpu_model_expansion(CpuModelExpansionType type,
+ CpuModelInfo *model,
+ Error **errp)
+{
+ g_assert_not_reached();
+}
diff --git a/stubs/qmp-cpu-riscv.c b/stubs/qmp-cpu-riscv.c
index ce500ffa3f..a448f060e2 100644
--- a/stubs/qmp-cpu-riscv.c
+++ b/stubs/qmp-cpu-riscv.c
@@ -7,3 +7,11 @@ CpuDefinitionInfoList *qmp_query_riscv_cpu_definitions(Error **errp)
{
g_assert_not_reached();
}
+
+CpuModelExpansionInfo *
+qmp_query_riscv_cpu_model_expansion(CpuModelExpansionType type,
+ CpuModelInfo *model,
+ Error **errp)
+{
+ g_assert_not_reached();
+}
diff --git a/stubs/qmp-cpu-s390x.c b/stubs/qmp-cpu-s390x.c
index 4556072a22..e664ddd68d 100644
--- a/stubs/qmp-cpu-s390x.c
+++ b/stubs/qmp-cpu-s390x.c
@@ -10,6 +10,14 @@ CpuDefinitionInfoList *qmp_query_s390x_cpu_definitions(Error **errp)
g_assert_not_reached();
}
+CpuModelExpansionInfo *
+qmp_query_s390x_cpu_model_expansion(CpuModelExpansionType type,
+ CpuModelInfo *model,
+ Error **errp)
+{
+ g_assert_not_reached();
+}
+
CpuModelCompareInfo *
qmp_query_cpu_model_comparison(CpuModelInfo *infoa,
CpuModelInfo *infob,
diff --git a/stubs/qmp-cpu.c b/stubs/qmp-cpu.c
deleted file mode 100644
index ac185f09f2..0000000000
--- a/stubs/qmp-cpu.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-
-#include "qemu/osdep.h"
-#include "qapi/error.h"
-#include "qapi/qapi-commands-machine.h"
-
-CpuModelExpansionInfo *
-qmp_query_cpu_model_expansion(CpuModelExpansionType type,
- CpuModelInfo *model,
- Error **errp)
-{
- error_setg(errp, "CPU model expansion is not supported on this target");
- return NULL;
-}
diff --git a/target/arm/arm-qmp-cmds.c b/target/arm/arm-qmp-cmds.c
index 2614aea258..9d3a3d9aa4 100644
--- a/target/arm/arm-qmp-cmds.c
+++ b/target/arm/arm-qmp-cmds.c
@@ -203,14 +203,6 @@ qmp_query_arm_cpu_model_expansion(CpuModelExpansionType type,
return expansion_info;
}
-CpuModelExpansionInfo *
-qmp_query_cpu_model_expansion(CpuModelExpansionType type,
- CpuModelInfo *model,
- Error **errp)
-{
- return qmp_query_arm_cpu_model_expansion(type, model, errp);
-}
-
static void arm_cpu_add_definition(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
diff --git a/target/i386/cpu-system.c b/target/i386/cpu-system.c
index f85dc4a703..c03cece7bd 100644
--- a/target/i386/cpu-system.c
+++ b/target/i386/cpu-system.c
@@ -242,14 +242,6 @@ out:
return ret;
}
-CpuModelExpansionInfo *
-qmp_query_cpu_model_expansion(CpuModelExpansionType type,
- CpuModelInfo *model,
- Error **errp)
-{
- return qmp_query_i386_cpu_model_expansion(type, model, errp);
-}
-
void cpu_clear_apic_feature(CPUX86State *env)
{
env->features[FEAT_1_EDX] &= ~CPUID_APIC;
diff --git a/target/loongarch/loongarch-qmp-cmds.c b/target/loongarch/loongarch-qmp-cmds.c
index 59f8069d8f..99ccd47fce 100644
--- a/target/loongarch/loongarch-qmp-cmds.c
+++ b/target/loongarch/loongarch-qmp-cmds.c
@@ -135,11 +135,3 @@ qmp_query_loongarch_cpu_model_expansion(CpuModelExpansionType type,
return expansion_info;
}
-
-CpuModelExpansionInfo *
-qmp_query_cpu_model_expansion(CpuModelExpansionType type,
- CpuModelInfo *model,
- Error **errp)
-{
- return qmp_query_loongarch_cpu_model_expansion(type, model, errp);
-}
diff --git a/target/mips/system/mips-qmp-cmds.c b/target/mips/system/mips-qmp-cmds.c
index ccbdbf8877..66f70ddac6 100644
--- a/target/mips/system/mips-qmp-cmds.c
+++ b/target/mips/system/mips-qmp-cmds.c
@@ -13,15 +13,6 @@
#include "system/qmp-cpu.h"
#include "cpu.h"
-CpuModelExpansionInfo *
-qmp_query_cpu_model_expansion(CpuModelExpansionType type,
- CpuModelInfo *model,
- Error **errp)
-{
- error_setg(errp, "CPU model expansion is not supported on this target");
- return NULL;
-}
-
static void mips_cpu_add_definition(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
diff --git a/target/ppc/ppc-qmp-cmds.c b/target/ppc/ppc-qmp-cmds.c
index 1338233ee6..98ea8291ca 100644
--- a/target/ppc/ppc-qmp-cmds.c
+++ b/target/ppc/ppc-qmp-cmds.c
@@ -31,15 +31,6 @@
#include "cpu-models.h"
#include "cpu-qom.h"
-CpuModelExpansionInfo *
-qmp_query_cpu_model_expansion(CpuModelExpansionType type,
- CpuModelInfo *model,
- Error **errp)
-{
- error_setg(errp, "CPU model expansion is not supported on this target");
- return NULL;
-}
-
static void ppc_cpu_defs_entry(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
diff --git a/target/riscv/riscv-qmp-cmds.c b/target/riscv/riscv-qmp-cmds.c
index d60c6073bb..4d94cd9b51 100644
--- a/target/riscv/riscv-qmp-cmds.c
+++ b/target/riscv/riscv-qmp-cmds.c
@@ -227,11 +227,3 @@ qmp_query_riscv_cpu_model_expansion(CpuModelExpansionType type,
return expansion_info;
}
-
-CpuModelExpansionInfo *
-qmp_query_cpu_model_expansion(CpuModelExpansionType type,
- CpuModelInfo *model,
- Error **errp)
-{
- return qmp_query_riscv_cpu_model_expansion(type, model, errp);
-}
diff --git a/target/s390x/cpu_models_system.c b/target/s390x/cpu_models_system.c
index ccfc918b38..5cf6469f0c 100644
--- a/target/s390x/cpu_models_system.c
+++ b/target/s390x/cpu_models_system.c
@@ -260,14 +260,6 @@ qmp_query_s390x_cpu_model_expansion(CpuModelExpansionType type,
return expansion_info;
}
-CpuModelExpansionInfo *
-qmp_query_cpu_model_expansion(CpuModelExpansionType type,
- CpuModelInfo *model,
- Error **errp)
-{
- return qmp_query_s390x_cpu_model_expansion(type, model, errp);
-}
-
static void list_add_feat(const char *name, void *opaque)
{
strList **last = (strList **) opaque;