* [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
@ 2026-10-15 0:53 Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 1/8] target/arm: rename qmp_query_cpu_definitions to qmp_query_arm_cpu_definitions Pierrick Bouvier
` (11 more replies)
0 siblings, 12 replies; 19+ messages in thread
From: Pierrick Bouvier @ 2026-10-15 0:53 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Marc-André Lureau,
Markus Armbruster, Pierrick Bouvier
This series allows to link multiple targets that define
qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
target-specific ones and a single dispatcher. We didn't use yet the dispatcher
pattern, and it's the first situation where it appears to be a good fit.
A possible alternative would be to introduce this callback directly at
target-info level, which I think is a less desirable solution, since it would
ties this API to monitor.
If the approach here is accepted, I'll extend this series with
qmp_query_cpu_model_expansion which follows the same pattern.
With this, we'll be free to link together almost all the base architectures.
Pierrick Bouvier (8):
target/arm: rename qmp_query_cpu_definitions to
qmp_query_arm_cpu_definitions
target/i386: rename qmp_query_cpu_definitions to
qmp_query_i386_cpu_definitions
target/loongarch: rename to qmp_query_loongarch_cpu_definitions
target/mips: rename qmp_query_cpu_definitions to
qmp_query_mips_cpu_definitions
target/ppc: rename qmp_query_cpu_definitions to
qmp_query_ppc_cpu_definitions
target/riscv: rename to qmp_query_cpu_definitions to
qmp_query_riscv_cpu_definitions
target/s390x: rename qmp_query_cpu_definitions to
qmp_query_s390x_cpu_definitions
qmp: reimplement qmp_query_cpu_definitions as a dispatcher function
hw/core/machine-qmp-cmds.c | 32 +++++++++++++++++++++++++++
include/system/qmp-cpu.h | 20 +++++++++++++++++
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 | 3 ++-
target/i386/cpu.c | 3 ++-
target/loongarch/loongarch-qmp-cmds.c | 3 ++-
target/mips/system/mips-qmp-cmds.c | 3 ++-
target/ppc/ppc-qmp-cmds.c | 3 ++-
target/riscv/riscv-qmp-cmds.c | 3 ++-
target/s390x/cpu_models_system.c | 3 ++-
18 files changed, 132 insertions(+), 14 deletions(-)
create mode 100644 include/system/qmp-cpu.h
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
--
2.43.0
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 1/8] target/arm: rename qmp_query_cpu_definitions to qmp_query_arm_cpu_definitions
2026-10-15 0:53 [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Pierrick Bouvier
@ 2026-10-15 0:53 ` Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 2/8] target/i386: rename qmp_query_cpu_definitions to qmp_query_i386_cpu_definitions Pierrick Bouvier
` (10 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Pierrick Bouvier @ 2026-10-15 0:53 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Marc-André Lureau,
Markus Armbruster, Pierrick Bouvier
In a future commit, a single target-agnostic qmp_query_cpu_definitions()
will dispatch call to the per-architecture implementations based on
target_arch(). Introduce the header holding those declarations and
rename the arm implementation.
We keep the existing qmp_query_cpu_definitions() function to not break
the build.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
---
include/system/qmp-cpu.h | 14 ++++++++++++++
target/arm/arm-qmp-cmds.c | 8 +++++++-
2 files changed, 21 insertions(+), 1 deletion(-)
create mode 100644 include/system/qmp-cpu.h
diff --git a/include/system/qmp-cpu.h b/include/system/qmp-cpu.h
new file mode 100644
index 00000000000..e969aec667a
--- /dev/null
+++ b/include/system/qmp-cpu.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Per-architecture implementations of CPU-related QMP commands.
+ */
+
+#ifndef SYSTEM_QMP_CPU_H
+#define SYSTEM_QMP_CPU_H
+
+#include "qapi/error.h"
+#include "qapi/qapi-types-machine.h"
+
+CpuDefinitionInfoList *qmp_query_arm_cpu_definitions(Error **errp);
+
+#endif
diff --git a/target/arm/arm-qmp-cmds.c b/target/arm/arm-qmp-cmds.c
index 83ec95c290f..d227a06e2c6 100644
--- a/target/arm/arm-qmp-cmds.c
+++ b/target/arm/arm-qmp-cmds.c
@@ -28,6 +28,7 @@
#include "qapi/visitor.h"
#include "qapi/qobject-input-visitor.h"
#include "qapi/qapi-commands-machine.h"
+#include "system/qmp-cpu.h"
#include "qapi/qapi-commands-misc-arm.h"
#include "qobject/qdict.h"
#include "qom/qom-qobject.h"
@@ -216,7 +217,7 @@ static void arm_cpu_add_definition(gpointer data, gpointer user_data)
QAPI_LIST_PREPEND(*cpu_list, info);
}
-CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
+CpuDefinitionInfoList *qmp_query_arm_cpu_definitions(Error **errp)
{
CpuDefinitionInfoList *cpu_list = NULL;
GSList *list;
@@ -227,3 +228,8 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
return cpu_list;
}
+
+CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
+{
+ return qmp_query_arm_cpu_definitions(errp);
+}
--
2.43.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 2/8] target/i386: rename qmp_query_cpu_definitions to qmp_query_i386_cpu_definitions
2026-10-15 0:53 [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 1/8] target/arm: rename qmp_query_cpu_definitions to qmp_query_arm_cpu_definitions Pierrick Bouvier
@ 2026-10-15 0:53 ` Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 3/8] target/loongarch: rename to qmp_query_loongarch_cpu_definitions Pierrick Bouvier
` (9 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Pierrick Bouvier @ 2026-10-15 0:53 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Marc-André Lureau,
Markus Armbruster, Pierrick Bouvier
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
---
include/system/qmp-cpu.h | 1 +
target/i386/cpu.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/system/qmp-cpu.h b/include/system/qmp-cpu.h
index e969aec667a..84b78c3a097 100644
--- a/include/system/qmp-cpu.h
+++ b/include/system/qmp-cpu.h
@@ -10,5 +10,6 @@
#include "qapi/qapi-types-machine.h"
CpuDefinitionInfoList *qmp_query_arm_cpu_definitions(Error **errp);
+CpuDefinitionInfoList *qmp_query_i386_cpu_definitions(Error **errp);
#endif
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 74eebeabd7a..dc762b802e1 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -45,6 +45,7 @@
#include "monitor/hmp.h"
#include "system/reset.h"
#include "qapi/qapi-commands-machine.h"
+#include "system/qmp-cpu.h"
#include "system/address-spaces.h"
#include "hw/core/boards.h"
#include "hw/i386/sgx-epc.h"
@@ -8191,7 +8192,7 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data)
QAPI_LIST_PREPEND(*cpu_list, info);
}
-CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
+CpuDefinitionInfoList *qmp_query_i386_cpu_definitions(Error **errp)
{
CpuDefinitionInfoList *cpu_list = NULL;
GSList *list = get_sorted_cpu_model_list();
@@ -8200,6 +8201,11 @@ CpuDefinitionInfoList *qmp_query_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)
--
2.43.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 3/8] target/loongarch: rename to qmp_query_loongarch_cpu_definitions
2026-10-15 0:53 [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 1/8] target/arm: rename qmp_query_cpu_definitions to qmp_query_arm_cpu_definitions Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 2/8] target/i386: rename qmp_query_cpu_definitions to qmp_query_i386_cpu_definitions Pierrick Bouvier
@ 2026-10-15 0:53 ` Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 4/8] target/mips: rename qmp_query_cpu_definitions to qmp_query_mips_cpu_definitions Pierrick Bouvier
` (8 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Pierrick Bouvier @ 2026-10-15 0:53 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Marc-André Lureau,
Markus Armbruster, Pierrick Bouvier
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
---
include/system/qmp-cpu.h | 1 +
target/loongarch/loongarch-qmp-cmds.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/system/qmp-cpu.h b/include/system/qmp-cpu.h
index 84b78c3a097..dbca230ac6f 100644
--- a/include/system/qmp-cpu.h
+++ b/include/system/qmp-cpu.h
@@ -11,5 +11,6 @@
CpuDefinitionInfoList *qmp_query_arm_cpu_definitions(Error **errp);
CpuDefinitionInfoList *qmp_query_i386_cpu_definitions(Error **errp);
+CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions(Error **errp);
#endif
diff --git a/target/loongarch/loongarch-qmp-cmds.c b/target/loongarch/loongarch-qmp-cmds.c
index f053f22bb8c..dadf5de889d 100644
--- a/target/loongarch/loongarch-qmp-cmds.c
+++ b/target/loongarch/loongarch-qmp-cmds.c
@@ -10,6 +10,7 @@
#include "qemu/target-info.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-machine.h"
+#include "system/qmp-cpu.h"
#include "cpu.h"
#include "qobject/qdict.h"
#include "qapi/qobject-input-visitor.h"
@@ -28,7 +29,7 @@ static void loongarch_cpu_add_definition(gpointer data, gpointer user_data)
QAPI_LIST_PREPEND(*cpu_list, info);
}
-CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
+CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions(Error **errp)
{
CpuDefinitionInfoList *cpu_list = NULL;
GSList *list;
@@ -40,6 +41,11 @@ CpuDefinitionInfoList *qmp_query_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
--
2.43.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 4/8] target/mips: rename qmp_query_cpu_definitions to qmp_query_mips_cpu_definitions
2026-10-15 0:53 [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Pierrick Bouvier
` (2 preceding siblings ...)
2026-10-15 0:53 ` [PATCH 3/8] target/loongarch: rename to qmp_query_loongarch_cpu_definitions Pierrick Bouvier
@ 2026-10-15 0:53 ` Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 5/8] target/ppc: rename qmp_query_cpu_definitions to qmp_query_ppc_cpu_definitions Pierrick Bouvier
` (7 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Pierrick Bouvier @ 2026-10-15 0:53 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Marc-André Lureau,
Markus Armbruster, Pierrick Bouvier
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
---
include/system/qmp-cpu.h | 1 +
target/mips/system/mips-qmp-cmds.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/system/qmp-cpu.h b/include/system/qmp-cpu.h
index dbca230ac6f..4267adfdc03 100644
--- a/include/system/qmp-cpu.h
+++ b/include/system/qmp-cpu.h
@@ -12,5 +12,6 @@
CpuDefinitionInfoList *qmp_query_arm_cpu_definitions(Error **errp);
CpuDefinitionInfoList *qmp_query_i386_cpu_definitions(Error **errp);
CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions(Error **errp);
+CpuDefinitionInfoList *qmp_query_mips_cpu_definitions(Error **errp);
#endif
diff --git a/target/mips/system/mips-qmp-cmds.c b/target/mips/system/mips-qmp-cmds.c
index b6a2874f2dd..560c7915365 100644
--- a/target/mips/system/mips-qmp-cmds.c
+++ b/target/mips/system/mips-qmp-cmds.c
@@ -10,6 +10,7 @@
#include "qemu/target-info.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-machine.h"
+#include "system/qmp-cpu.h"
#include "cpu.h"
CpuModelExpansionInfo *
@@ -36,7 +37,7 @@ static void mips_cpu_add_definition(gpointer data, gpointer user_data)
QAPI_LIST_PREPEND(*cpu_list, info);
}
-CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
+CpuDefinitionInfoList *qmp_query_mips_cpu_definitions(Error **errp)
{
CpuDefinitionInfoList *cpu_list = NULL;
GSList *list;
@@ -47,3 +48,8 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
return cpu_list;
}
+
+CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
+{
+ return qmp_query_mips_cpu_definitions(errp);
+}
--
2.43.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 5/8] target/ppc: rename qmp_query_cpu_definitions to qmp_query_ppc_cpu_definitions
2026-10-15 0:53 [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Pierrick Bouvier
` (3 preceding siblings ...)
2026-10-15 0:53 ` [PATCH 4/8] target/mips: rename qmp_query_cpu_definitions to qmp_query_mips_cpu_definitions Pierrick Bouvier
@ 2026-10-15 0:53 ` Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 6/8] target/riscv: rename to qmp_query_cpu_definitions to qmp_query_riscv_cpu_definitions Pierrick Bouvier
` (6 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Pierrick Bouvier @ 2026-10-15 0:53 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Marc-André Lureau,
Markus Armbruster, Pierrick Bouvier
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
---
include/system/qmp-cpu.h | 1 +
target/ppc/ppc-qmp-cmds.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/system/qmp-cpu.h b/include/system/qmp-cpu.h
index 4267adfdc03..fba0e11d5e2 100644
--- a/include/system/qmp-cpu.h
+++ b/include/system/qmp-cpu.h
@@ -13,5 +13,6 @@ CpuDefinitionInfoList *qmp_query_arm_cpu_definitions(Error **errp);
CpuDefinitionInfoList *qmp_query_i386_cpu_definitions(Error **errp);
CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions(Error **errp);
CpuDefinitionInfoList *qmp_query_mips_cpu_definitions(Error **errp);
+CpuDefinitionInfoList *qmp_query_ppc_cpu_definitions(Error **errp);
#endif
diff --git a/target/ppc/ppc-qmp-cmds.c b/target/ppc/ppc-qmp-cmds.c
index 96228919966..fe35ae1ac04 100644
--- a/target/ppc/ppc-qmp-cmds.c
+++ b/target/ppc/ppc-qmp-cmds.c
@@ -27,6 +27,7 @@
#include "qemu/ctype.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-machine.h"
+#include "system/qmp-cpu.h"
#include "cpu-models.h"
#include "cpu-qom.h"
@@ -53,7 +54,7 @@ static void ppc_cpu_defs_entry(gpointer data, gpointer user_data)
QAPI_LIST_PREPEND(*first, info);
}
-CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
+CpuDefinitionInfoList *qmp_query_ppc_cpu_definitions(Error **errp)
{
CpuDefinitionInfoList *cpu_list = NULL;
GSList *list;
@@ -82,3 +83,8 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
return cpu_list;
}
+
+CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
+{
+ return qmp_query_ppc_cpu_definitions(errp);
+}
--
2.43.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 6/8] target/riscv: rename to qmp_query_cpu_definitions to qmp_query_riscv_cpu_definitions
2026-10-15 0:53 [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Pierrick Bouvier
` (4 preceding siblings ...)
2026-10-15 0:53 ` [PATCH 5/8] target/ppc: rename qmp_query_cpu_definitions to qmp_query_ppc_cpu_definitions Pierrick Bouvier
@ 2026-10-15 0:53 ` Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 7/8] target/s390x: rename qmp_query_cpu_definitions to qmp_query_s390x_cpu_definitions Pierrick Bouvier
` (5 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Pierrick Bouvier @ 2026-10-15 0:53 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Marc-André Lureau,
Markus Armbruster, Pierrick Bouvier
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
---
include/system/qmp-cpu.h | 1 +
target/riscv/riscv-qmp-cmds.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/system/qmp-cpu.h b/include/system/qmp-cpu.h
index fba0e11d5e2..c1bfdd679e2 100644
--- a/include/system/qmp-cpu.h
+++ b/include/system/qmp-cpu.h
@@ -14,5 +14,6 @@ CpuDefinitionInfoList *qmp_query_i386_cpu_definitions(Error **errp);
CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions(Error **errp);
CpuDefinitionInfoList *qmp_query_mips_cpu_definitions(Error **errp);
CpuDefinitionInfoList *qmp_query_ppc_cpu_definitions(Error **errp);
+CpuDefinitionInfoList *qmp_query_riscv_cpu_definitions(Error **errp);
#endif
diff --git a/target/riscv/riscv-qmp-cmds.c b/target/riscv/riscv-qmp-cmds.c
index 2647deef916..ccd6ae1d5cf 100644
--- a/target/riscv/riscv-qmp-cmds.c
+++ b/target/riscv/riscv-qmp-cmds.c
@@ -26,6 +26,7 @@
#include "qapi/error.h"
#include "qapi/qapi-commands-machine.h"
+#include "system/qmp-cpu.h"
#include "qobject/qbool.h"
#include "qobject/qdict.h"
#include "qapi/qobject-input-visitor.h"
@@ -54,7 +55,7 @@ static void riscv_cpu_add_definition(gpointer data, gpointer user_data)
QAPI_LIST_PREPEND(*cpu_list, info);
}
-CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
+CpuDefinitionInfoList *qmp_query_riscv_cpu_definitions(Error **errp)
{
CpuDefinitionInfoList *cpu_list = NULL;
GSList *list = object_class_get_list(TYPE_RISCV_CPU, false);
@@ -65,6 +66,11 @@ CpuDefinitionInfoList *qmp_query_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)) {
--
2.43.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 7/8] target/s390x: rename qmp_query_cpu_definitions to qmp_query_s390x_cpu_definitions
2026-10-15 0:53 [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Pierrick Bouvier
` (5 preceding siblings ...)
2026-10-15 0:53 ` [PATCH 6/8] target/riscv: rename to qmp_query_cpu_definitions to qmp_query_riscv_cpu_definitions Pierrick Bouvier
@ 2026-10-15 0:53 ` Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 8/8] qmp: reimplement qmp_query_cpu_definitions as a dispatcher function Pierrick Bouvier
` (4 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Pierrick Bouvier @ 2026-10-15 0:53 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Marc-André Lureau,
Markus Armbruster, Pierrick Bouvier
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
---
include/system/qmp-cpu.h | 1 +
target/s390x/cpu_models_system.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/system/qmp-cpu.h b/include/system/qmp-cpu.h
index c1bfdd679e2..f0e0d427e3b 100644
--- a/include/system/qmp-cpu.h
+++ b/include/system/qmp-cpu.h
@@ -15,5 +15,6 @@ CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions(Error **errp);
CpuDefinitionInfoList *qmp_query_mips_cpu_definitions(Error **errp);
CpuDefinitionInfoList *qmp_query_ppc_cpu_definitions(Error **errp);
CpuDefinitionInfoList *qmp_query_riscv_cpu_definitions(Error **errp);
+CpuDefinitionInfoList *qmp_query_s390x_cpu_definitions(Error **errp);
#endif
diff --git a/target/s390x/cpu_models_system.c b/target/s390x/cpu_models_system.c
index 5b846048675..f963ca5248a 100644
--- a/target/s390x/cpu_models_system.c
+++ b/target/s390x/cpu_models_system.c
@@ -20,6 +20,7 @@
#include "qapi/qobject-input-visitor.h"
#include "qobject/qdict.h"
#include "qapi/qapi-commands-machine.h"
+#include "system/qmp-cpu.h"
static void list_add_feat(const char *name, void *opaque);
@@ -82,7 +83,7 @@ static void create_cpu_model_list(ObjectClass *klass, void *opaque)
QAPI_LIST_PREPEND(*cpu_list, info);
}
-CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
+CpuDefinitionInfoList *qmp_query_s390x_cpu_definitions(Error **errp)
{
struct CpuDefinitionInfoListData list_data = {
.list = NULL,
@@ -96,6 +97,11 @@ CpuDefinitionInfoList *qmp_query_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
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 8/8] qmp: reimplement qmp_query_cpu_definitions as a dispatcher function
2026-10-15 0:53 [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Pierrick Bouvier
` (6 preceding siblings ...)
2026-10-15 0:53 ` [PATCH 7/8] target/s390x: rename qmp_query_cpu_definitions to qmp_query_s390x_cpu_definitions Pierrick Bouvier
@ 2026-10-15 0:53 ` Pierrick Bouvier
2026-10-15 5:57 ` Markus Armbruster
2026-10-15 2:20 ` [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Yonggang Luo
` (3 subsequent siblings)
11 siblings, 1 reply; 19+ messages in thread
From: Pierrick Bouvier @ 2026-10-15 0:53 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Marc-André Lureau,
Markus Armbruster, Pierrick Bouvier
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 <pierrick.bouvier@oss.qualcomm.com>
---
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
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
2026-10-15 0:53 [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Pierrick Bouvier
` (7 preceding siblings ...)
2026-10-15 0:53 ` [PATCH 8/8] qmp: reimplement qmp_query_cpu_definitions as a dispatcher function Pierrick Bouvier
@ 2026-10-15 2:20 ` Yonggang Luo
2026-10-15 4:46 ` Yonggang Luo
` (2 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Yonggang Luo @ 2026-10-15 2:20 UTC (permalink / raw)
To: Pierrick Bouvier
Cc: qemu-devel, Philippe Mathieu-Daudé, Marc-André Lureau,
Markus Armbruster
On Thu, Oct 15, 2026 at 8:55 AM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> This series allows to link multiple targets that define
> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
> pattern, and it's the first situation where it appears to be a good fit.
>
> A possible alternative would be to introduce this callback directly at
> target-info level, which I think is a less desirable solution, since it would
> ties this API to monitor.
I tried this way and it is much better I think.
>
> If the approach here is accepted, I'll extend this series with
> qmp_query_cpu_model_expansion which follows the same pattern.
> With this, we'll be free to link together almost all the base architectures.
>
> Pierrick Bouvier (8):
> target/arm: rename qmp_query_cpu_definitions to
> qmp_query_arm_cpu_definitions
> target/i386: rename qmp_query_cpu_definitions to
> qmp_query_i386_cpu_definitions
> target/loongarch: rename to qmp_query_loongarch_cpu_definitions
> target/mips: rename qmp_query_cpu_definitions to
> qmp_query_mips_cpu_definitions
> target/ppc: rename qmp_query_cpu_definitions to
> qmp_query_ppc_cpu_definitions
> target/riscv: rename to qmp_query_cpu_definitions to
> qmp_query_riscv_cpu_definitions
> target/s390x: rename qmp_query_cpu_definitions to
> qmp_query_s390x_cpu_definitions
> qmp: reimplement qmp_query_cpu_definitions as a dispatcher function
>
> hw/core/machine-qmp-cmds.c | 32 +++++++++++++++++++++++++++
> include/system/qmp-cpu.h | 20 +++++++++++++++++
> 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 ------
Introduce this callback directly at target-info level wil avoid these
stubs/qmp-*, basically we indeed can remove more stubs. maybe
qmp-cpu.c be removed.
> target/arm/arm-qmp-cmds.c | 3 ++-
> target/i386/cpu.c | 3 ++-
> target/loongarch/loongarch-qmp-cmds.c | 3 ++-
> target/mips/system/mips-qmp-cmds.c | 3 ++-
> target/ppc/ppc-qmp-cmds.c | 3 ++-
> target/riscv/riscv-qmp-cmds.c | 3 ++-
> target/s390x/cpu_models_system.c | 3 ++-
> 18 files changed, 132 insertions(+), 14 deletions(-)
> create mode 100644 include/system/qmp-cpu.h
> 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
>
> --
> 2.43.0
>
>
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
2026-10-15 0:53 [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Pierrick Bouvier
` (8 preceding siblings ...)
2026-10-15 2:20 ` [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Yonggang Luo
@ 2026-10-15 4:46 ` Yonggang Luo
2026-10-15 5:58 ` Markus Armbruster
2026-10-15 7:59 ` Daniel P. Berrangé
11 siblings, 0 replies; 19+ messages in thread
From: Yonggang Luo @ 2026-10-15 4:46 UTC (permalink / raw)
To: Pierrick Bouvier
Cc: qemu-devel, Philippe Mathieu-Daudé, Marc-André Lureau,
Markus Armbruster
On Thu, Oct 15, 2026 at 8:55 AM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> This series allows to link multiple targets that define
> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
> pattern, and it's the first situation where it appears to be a good fit.
>
> A possible alternative would be to introduce this callback directly at
> target-info level, which I think is a less desirable solution, since it would
> ties this API to monitor.
Here is my DRAFT patch, you can take a look about this direction, and
change far less code.
https://lore.kernel.org/qemu-devel/20261015044104.879-1-luoyonggang@gmail.com/
>
> If the approach here is accepted, I'll extend this series with
> qmp_query_cpu_model_expansion which follows the same pattern.
> With this, we'll be free to link together almost all the base architectures.
>
> Pierrick Bouvier (8):
> target/arm: rename qmp_query_cpu_definitions to
> qmp_query_arm_cpu_definitions
> target/i386: rename qmp_query_cpu_definitions to
> qmp_query_i386_cpu_definitions
> target/loongarch: rename to qmp_query_loongarch_cpu_definitions
> target/mips: rename qmp_query_cpu_definitions to
> qmp_query_mips_cpu_definitions
> target/ppc: rename qmp_query_cpu_definitions to
> qmp_query_ppc_cpu_definitions
> target/riscv: rename to qmp_query_cpu_definitions to
> qmp_query_riscv_cpu_definitions
> target/s390x: rename qmp_query_cpu_definitions to
> qmp_query_s390x_cpu_definitions
> qmp: reimplement qmp_query_cpu_definitions as a dispatcher function
>
> hw/core/machine-qmp-cmds.c | 32 +++++++++++++++++++++++++++
> include/system/qmp-cpu.h | 20 +++++++++++++++++
> 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 | 3 ++-
> target/i386/cpu.c | 3 ++-
> target/loongarch/loongarch-qmp-cmds.c | 3 ++-
> target/mips/system/mips-qmp-cmds.c | 3 ++-
> target/ppc/ppc-qmp-cmds.c | 3 ++-
> target/riscv/riscv-qmp-cmds.c | 3 ++-
> target/s390x/cpu_models_system.c | 3 ++-
> 18 files changed, 132 insertions(+), 14 deletions(-)
> create mode 100644 include/system/qmp-cpu.h
> 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
>
> --
> 2.43.0
>
>
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 8/8] qmp: reimplement qmp_query_cpu_definitions as a dispatcher function
2026-10-15 0:53 ` [PATCH 8/8] qmp: reimplement qmp_query_cpu_definitions as a dispatcher function Pierrick Bouvier
@ 2026-10-15 5:57 ` Markus Armbruster
2026-10-15 6:14 ` Pierrick Bouvier
0 siblings, 1 reply; 19+ messages in thread
From: Markus Armbruster @ 2026-10-15 5:57 UTC (permalink / raw)
To: Pierrick Bouvier
Cc: qemu-devel, Philippe Mathieu-Daudé, Marc-André Lureau
Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:
> 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 <pierrick.bouvier@oss.qualcomm.com>
> ---
> 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,
I believe the stubs are needed to make hw/core/machine-qmp-cmds.c link
when targets are compiled out. Suggest to briefly explain that in the
commit message.
[...]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
2026-10-15 0:53 [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Pierrick Bouvier
` (9 preceding siblings ...)
2026-10-15 4:46 ` Yonggang Luo
@ 2026-10-15 5:58 ` Markus Armbruster
2026-10-15 6:13 ` Pierrick Bouvier
2026-10-15 7:57 ` Daniel P. Berrangé
2026-10-15 7:59 ` Daniel P. Berrangé
11 siblings, 2 replies; 19+ messages in thread
From: Markus Armbruster @ 2026-10-15 5:58 UTC (permalink / raw)
To: Pierrick Bouvier
Cc: qemu-devel, Philippe Mathieu-Daudé, Marc-André Lureau
Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:
> This series allows to link multiple targets that define
> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
> pattern, and it's the first situation where it appears to be a good fit.
>
> A possible alternative would be to introduce this callback directly at
> target-info level, which I think is a less desirable solution, since it would
> ties this API to monitor.
I'm curious... why would such a tie be undesirable?
> If the approach here is accepted, I'll extend this series with
> qmp_query_cpu_model_expansion which follows the same pattern.
> With this, we'll be free to link together almost all the base architectures.
Series
Acked-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
2026-10-15 5:58 ` Markus Armbruster
@ 2026-10-15 6:13 ` Pierrick Bouvier
2026-10-15 6:36 ` Yonggang Luo
2026-10-15 7:57 ` Daniel P. Berrangé
1 sibling, 1 reply; 19+ messages in thread
From: Pierrick Bouvier @ 2026-10-15 6:13 UTC (permalink / raw)
To: Markus Armbruster
Cc: qemu-devel, Philippe Mathieu-Daudé, Marc-André Lureau
On 10/14/26 10:58 PM, Markus Armbruster wrote:
> Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:
>
>> This series allows to link multiple targets that define
>> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
>> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
>> pattern, and it's the first situation where it appears to be a good fit.
>>
>> A possible alternative would be to introduce this callback directly at
>> target-info level, which I think is a less desirable solution, since it would
>> ties this API to monitor.
>
> I'm curious... why would such a tie be undesirable?
>
We have a unique definition of target-info for all targets
(https://gitlab.com/qemu-project/qemu/-/blob/master/target-info-def.c),
which is simple and nice.
We could consider adding callbacks in this "generic" file only if they
are implemented for all targets, but as we can see in this series, only
a few targets implement this. It would be more boilerplate for the same
result.
IMHO the two concerned functions (qmp_query_cpu*) look more like an
exception than a proper rule. dump functions (posted in another series)
are more related to cpu, and not to target themselves.
I would happy to revisit this if community prefers to go in a different
direction though.
>> If the approach here is accepted, I'll extend this series with
>> qmp_query_cpu_model_expansion which follows the same pattern.
>> With this, we'll be free to link together almost all the base architectures.
>
> Series
> Acked-by: Markus Armbruster <armbru@redhat.com>
>
Regards,
Pierrick
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 8/8] qmp: reimplement qmp_query_cpu_definitions as a dispatcher function
2026-10-15 5:57 ` Markus Armbruster
@ 2026-10-15 6:14 ` Pierrick Bouvier
0 siblings, 0 replies; 19+ messages in thread
From: Pierrick Bouvier @ 2026-10-15 6:14 UTC (permalink / raw)
To: Markus Armbruster
Cc: qemu-devel, Philippe Mathieu-Daudé, Marc-André Lureau
On 10/14/26 10:57 PM, Markus Armbruster wrote:
> Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:
>
>> 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 <pierrick.bouvier@oss.qualcomm.com>
>> ---
>> 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,
>
> I believe the stubs are needed to make hw/core/machine-qmp-cmds.c link
> when targets are compiled out. Suggest to briefly explain that in the
> commit message.
>
That's correct.
I'll add it to commit message so it's clearer.
> [...]
>
Thanks,
Pierrick
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
2026-10-15 6:13 ` Pierrick Bouvier
@ 2026-10-15 6:36 ` Yonggang Luo
0 siblings, 0 replies; 19+ messages in thread
From: Yonggang Luo @ 2026-10-15 6:36 UTC (permalink / raw)
To: Pierrick Bouvier
Cc: Markus Armbruster, qemu-devel, Philippe Mathieu-Daudé,
Marc-André Lureau
On Thu, Oct 15, 2026 at 2:14 PM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> On 10/14/26 10:58 PM, Markus Armbruster wrote:
> > Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:
> >
> >> This series allows to link multiple targets that define
> >> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
> >> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
> >> pattern, and it's the first situation where it appears to be a good fit.
> >>
> >> A possible alternative would be to introduce this callback directly at
> >> target-info level, which I think is a less desirable solution, since it would
> >> ties this API to monitor.
> >
> > I'm curious... why would such a tie be undesirable?
> >
>
> We have a unique definition of target-info for all targets
> (https://gitlab.com/qemu-project/qemu/-/blob/master/target-info-def.c),
> which is simple and nice.
>
> We could consider adding callbacks in this "generic" file only if they
> are implemented for all targets, but as we can see in this series, only
> a few targets implement this. It would be more boilerplate for the same
> result.
I personally think we can call it "generic" if three or more targets
are implemented, otherwise it's too restricted. And also get it hard if
new targets want to leverage/implement it.
Anyway, this series is still fine, I have no objection, just some points.
>
> IMHO the two concerned functions (qmp_query_cpu*) look more like an
> exception than a proper rule. dump functions (posted in another series)
> are more related to cpu, and not to target themselves.
>
> I would happy to revisit this if community prefers to go in a different
> direction though.
>
> >> If the approach here is accepted, I'll extend this series with
> >> qmp_query_cpu_model_expansion which follows the same pattern.
> >> With this, we'll be free to link together almost all the base architectures.
> >
> > Series
> > Acked-by: Markus Armbruster <armbru@redhat.com>
> >
>
> Regards,
> Pierrick
>
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
2026-10-15 5:58 ` Markus Armbruster
2026-10-15 6:13 ` Pierrick Bouvier
@ 2026-10-15 7:57 ` Daniel P. Berrangé
2026-10-15 17:57 ` Pierrick Bouvier
1 sibling, 1 reply; 19+ messages in thread
From: Daniel P. Berrangé @ 2026-10-15 7:57 UTC (permalink / raw)
To: Markus Armbruster
Cc: Pierrick Bouvier, qemu-devel, Philippe Mathieu-Daudé,
Marc-André Lureau
On Thu, Oct 15, 2026 at 07:58:29AM +0200, Markus Armbruster wrote:
> Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:
>
> > This series allows to link multiple targets that define
> > qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
> > target-specific ones and a single dispatcher. We didn't use yet the dispatcher
> > pattern, and it's the first situation where it appears to be a good fit.
> >
> > A possible alternative would be to introduce this callback directly at
> > target-info level, which I think is a less desirable solution, since it would
> > ties this API to monitor.
>
> I'm curious... why would such a tie be undesirable?
I don't think target-info should be involved at all, it is a problem
to solve in the CPU type system. The CPU definitions are introspecting
sub-classes of TYPE_CPU.
IMHO the right way to solve this is for CPUClass to gain a callback for
introspection, and for each target to provide an impl of that callback.
There should only be a single qmp_query_cpu_definitions method that
introspects all registered TYPE_CPU subclasses. That way in a
multi-target binary, the introspection will return info for all
CPUs for all compiled in targets.
That would need refactoring of the current qmp_query_cpu_definitions
methods which is a bigger job. This series as is, is a reasonable
small initial stepping stone to make it possible to link the binaries,
before a later followup patch to do the full refactoring to get the
desirable API semantics.
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
2026-10-15 0:53 [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Pierrick Bouvier
` (10 preceding siblings ...)
2026-10-15 5:58 ` Markus Armbruster
@ 2026-10-15 7:59 ` Daniel P. Berrangé
11 siblings, 0 replies; 19+ messages in thread
From: Daniel P. Berrangé @ 2026-10-15 7:59 UTC (permalink / raw)
To: Pierrick Bouvier
Cc: qemu-devel, Philippe Mathieu-Daudé, Marc-André Lureau,
Markus Armbruster
On Thu, Oct 15, 2026 at 12:53:47AM +0000, Pierrick Bouvier wrote:
> This series allows to link multiple targets that define
> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
> pattern, and it's the first situation where it appears to be a good fit.
>
> A possible alternative would be to introduce this callback directly at
> target-info level, which I think is a less desirable solution, since it would
> ties this API to monitor.
>
> If the approach here is accepted, I'll extend this series with
> qmp_query_cpu_model_expansion which follows the same pattern.
> With this, we'll be free to link together almost all the base architectures.
>
> Pierrick Bouvier (8):
> target/arm: rename qmp_query_cpu_definitions to
> qmp_query_arm_cpu_definitions
> target/i386: rename qmp_query_cpu_definitions to
> qmp_query_i386_cpu_definitions
> target/loongarch: rename to qmp_query_loongarch_cpu_definitions
> target/mips: rename qmp_query_cpu_definitions to
> qmp_query_mips_cpu_definitions
> target/ppc: rename qmp_query_cpu_definitions to
> qmp_query_ppc_cpu_definitions
> target/riscv: rename to qmp_query_cpu_definitions to
> qmp_query_riscv_cpu_definitions
> target/s390x: rename qmp_query_cpu_definitions to
> qmp_query_s390x_cpu_definitions
> qmp: reimplement qmp_query_cpu_definitions as a dispatcher function
>
> hw/core/machine-qmp-cmds.c | 32 +++++++++++++++++++++++++++
> include/system/qmp-cpu.h | 20 +++++++++++++++++
> 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 | 3 ++-
> target/i386/cpu.c | 3 ++-
> target/loongarch/loongarch-qmp-cmds.c | 3 ++-
> target/mips/system/mips-qmp-cmds.c | 3 ++-
> target/ppc/ppc-qmp-cmds.c | 3 ++-
> target/riscv/riscv-qmp-cmds.c | 3 ++-
> target/s390x/cpu_models_system.c | 3 ++-
> 18 files changed, 132 insertions(+), 14 deletions(-)
> create mode 100644 include/system/qmp-cpu.h
> 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
For series:
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
2026-10-15 7:57 ` Daniel P. Berrangé
@ 2026-10-15 17:57 ` Pierrick Bouvier
0 siblings, 0 replies; 19+ messages in thread
From: Pierrick Bouvier @ 2026-10-15 17:57 UTC (permalink / raw)
To: Daniel P. Berrangé, Markus Armbruster
Cc: qemu-devel, Philippe Mathieu-Daudé, Marc-André Lureau
On 10/15/2026 12:57 AM, Daniel P. Berrangé wrote:
> On Thu, Oct 15, 2026 at 07:58:29AM +0200, Markus Armbruster wrote:
>> Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:
>>
>>> This series allows to link multiple targets that define
>>> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
>>> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
>>> pattern, and it's the first situation where it appears to be a good fit.
>>>
>>> A possible alternative would be to introduce this callback directly at
>>> target-info level, which I think is a less desirable solution, since it would
>>> ties this API to monitor.
>>
>> I'm curious... why would such a tie be undesirable?
>
> I don't think target-info should be involved at all, it is a problem
> to solve in the CPU type system. The CPU definitions are introspecting
> sub-classes of TYPE_CPU.
>
> IMHO the right way to solve this is for CPUClass to gain a callback for
> introspection, and for each target to provide an impl of that callback.
>
> There should only be a single qmp_query_cpu_definitions method that
> introspects all registered TYPE_CPU subclasses. That way in a
> multi-target binary, the introspection will return info for all
> CPUs for all compiled in targets.
>
I was wondering if what we would like to expose is all targets, or only
the ones that have a cpu active.
> That would need refactoring of the current qmp_query_cpu_definitions
> methods which is a bigger job. This series as is, is a reasonable
> small initial stepping stone to make it possible to link the binaries,
> before a later followup patch to do the full refactoring to get the
> desirable API semantics.
>
That was the goal 👍.
> With regards,
> Daniel
Regards,
Pierrick
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2026-10-15 17:58 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-15 0:53 [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 1/8] target/arm: rename qmp_query_cpu_definitions to qmp_query_arm_cpu_definitions Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 2/8] target/i386: rename qmp_query_cpu_definitions to qmp_query_i386_cpu_definitions Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 3/8] target/loongarch: rename to qmp_query_loongarch_cpu_definitions Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 4/8] target/mips: rename qmp_query_cpu_definitions to qmp_query_mips_cpu_definitions Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 5/8] target/ppc: rename qmp_query_cpu_definitions to qmp_query_ppc_cpu_definitions Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 6/8] target/riscv: rename to qmp_query_cpu_definitions to qmp_query_riscv_cpu_definitions Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 7/8] target/s390x: rename qmp_query_cpu_definitions to qmp_query_s390x_cpu_definitions Pierrick Bouvier
2026-10-15 0:53 ` [PATCH 8/8] qmp: reimplement qmp_query_cpu_definitions as a dispatcher function Pierrick Bouvier
2026-10-15 5:57 ` Markus Armbruster
2026-10-15 6:14 ` Pierrick Bouvier
2026-10-15 2:20 ` [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication Yonggang Luo
2026-10-15 4:46 ` Yonggang Luo
2026-10-15 5:58 ` Markus Armbruster
2026-10-15 6:13 ` Pierrick Bouvier
2026-10-15 6:36 ` Yonggang Luo
2026-10-15 7:57 ` Daniel P. Berrangé
2026-10-15 17:57 ` Pierrick Bouvier
2026-10-15 7:59 ` Daniel P. Berrangé
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.