public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/27] monitor: Remove need of per-target handlers
@ 2026-04-10 19:52 Philippe Mathieu-Daudé
  2026-04-10 19:52 ` [PATCH v2 01/27] monitor: Have MonitorDef::get_value() always return int64_t type Philippe Mathieu-Daudé
                   ` (26 more replies)
  0 siblings, 27 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé

Changes needed for the single binary (and heterogeneous emulation).

Convert target_monitor_defs() and target_monitor_defs()
to SysemuCPUOps fields, adapting the 4 targets using these
'legacy' code.

Instead of filtering the commands per target / device at
build time, add a new field to HMPCommand to filter them
at runtime, allowing to compile the command array once.

Philippe Mathieu-Daudé (27):
  monitor: Have MonitorDef::get_value() always return int64_t type
  monitor: Remove target_long use in get_monitor_def()
  monitor: Reduce target-specific methods further
  monitor: Remove 'monitor/hmp-target.h' header
  monitor: Forward-declare the MonitorDef type
  cpus: Introduce SysemuCPUOps::monitor_defs hook
  target/i386: Replace target_monitor_defs -> SysemuCPUOps::monitor_defs
  target/m68k: Replace target_monitor_defs -> SysemuCPUOps::monitor_defs
  target/sparc: Replace target_monitor_defs ->
    SysemuCPUOps::monitor_defs
  monitor: Remove target_monitor_defs()
  cpus: Introduce SysemuCPUOps::monitor_get_register() hook
  target/riscv: Register target_get_monitor_def in SysemuCPUOps
  monitor: Remove target_get_monitor_def()
  monitor/meson: Use SPICE with migration HMP commands
  stubs: Rename monitor* -> qmp* files
  monitor: Make 'info via' a generic command
  monitor: Make Xen emulation commands generic ones
  system: Expose 'arch_init.h' as 'qemu/target-arch-defs.h'
  monitor: Introduce HMPCommand::arch_bitmask field
  hw/s390x: Reduce 'monitor/monitor.h' inclusions
  monitor: Do not check TARGET_S390X to build s390x commands
  monitor: Do not check TARGET_I386 to build target/i386/ commands
  monitor: Do not check TARGET_I386 to build 'info sgx' command
  monitor: Do not check TARGET_I386 to build 'info sev' command
  monitor: Do not check TARGET_I386/RISCV to build 'info mem' command
  monitor: Do not check multiple TARGET_* to build 'info tlb' command
  monitor: Merge hmp-target.c code within hmp-cmds.c

 MAINTAINERS                                   |  14 ++-
 include/hw/core/sysemu-cpu-ops.h              |  13 ++
 include/hw/s390x/storage-attributes.h         |   4 -
 include/hw/s390x/storage-keys.h               |   3 -
 include/monitor/hmp-target.h                  |  46 -------
 include/monitor/hmp.h                         |  21 ++++
 .../qemu/base-arch-defs.h                     |  10 +-
 include/qemu/typedefs.h                       |   1 +
 monitor/monitor-internal.h                    |   7 +-
 target/riscv/internals.h                      |   3 +
 hw/i386/kvm/xen-stubs.c                       |  12 ++
 hw/i386/sgx-hmp-stub.c                        |  16 +++
 hw/i386/sgx-stub.c                            |   6 -
 hw/i386/sgx.c                                 |   1 -
 hw/misc/mos6522-stub.c                        |  16 +++
 hw/pci/pci.c                                  |   2 +-
 hw/s390x/s390-skeys.c                         |   2 +
 hw/s390x/s390-stattrib.c                      |   2 +
 monitor/hmp-cmds.c                            |  41 ++++++-
 monitor/hmp-target.c                          | 115 ------------------
 monitor/hmp.c                                 |  53 +++++++-
 stubs/hmp-cmd-info_mem.c                      |  12 ++
 stubs/hmp-cmd-info_sev.c                      |  16 +++
 stubs/hmp-cmd-info_tlb.c                      |  12 ++
 stubs/hmp-cmds-hw-s390x.c                     |  15 +++
 stubs/hmp-cmds-target-i386.c                  |  13 ++
 stubs/{monitor-arm-gic.c => qmp-arm-gic.c}    |   0
 ...or-cpu-s390x-kvm.c => qmp-cpu-s390x-kvm.c} |   0
 .../{monitor-cpu-s390x.c => qmp-cpu-s390x.c}  |   0
 stubs/{monitor-cpu.c => qmp-cpu.c}            |   0
 stubs/{monitor-i386-rtc.c => qmp-i386-rtc.c}  |   0
 stubs/{monitor-i386-sev.c => qmp-i386-sev.c}  |   0
 stubs/{monitor-i386-sgx.c => qmp-i386-sgx.c}  |   0
 stubs/{monitor-i386-xen.c => qmp-i386-xen.c}  |   0
 stubs/target-get-monitor-def.c                |  29 -----
 stubs/target-monitor-defs.c                   |   7 --
 system/arch_init.c                            |   2 +-
 system/qdev-monitor.c                         |   2 +-
 system/vl.c                                   |   2 +-
 target/i386/cpu-apic.c                        |   1 -
 target/i386/cpu.c                             |  24 ++++
 target/i386/monitor.c                         |  26 ----
 target/i386/sev-system-stub.c                 |   6 -
 target/i386/sev.c                             |   1 -
 target/m68k/cpu.c                             |  18 +++
 target/m68k/monitor.c                         |  22 ----
 target/ppc/monitor.c                          |   2 -
 target/riscv/cpu.c                            |   1 +
 target/riscv/monitor.c                        |   5 +-
 target/sh4/monitor.c                          |   1 -
 target/sparc/cpu.c                            |  19 +++
 target/sparc/monitor.c                        |  19 ---
 target/xtensa/monitor.c                       |   1 -
 hmp-commands-info.hx                          |  26 ++--
 hmp-commands.hx                               |  13 +-
 hw/i386/meson.build                           |   1 +
 hw/misc/meson.build                           |   1 +
 migration/meson.build                         |   2 +-
 monitor/meson.build                           |   5 +-
 stubs/meson.build                             |  23 ++--
 60 files changed, 368 insertions(+), 347 deletions(-)
 delete mode 100644 include/monitor/hmp-target.h
 rename system/arch_init.h => include/qemu/base-arch-defs.h (92%)
 create mode 100644 hw/i386/sgx-hmp-stub.c
 create mode 100644 hw/misc/mos6522-stub.c
 delete mode 100644 monitor/hmp-target.c
 create mode 100644 stubs/hmp-cmd-info_mem.c
 create mode 100644 stubs/hmp-cmd-info_sev.c
 create mode 100644 stubs/hmp-cmd-info_tlb.c
 create mode 100644 stubs/hmp-cmds-hw-s390x.c
 create mode 100644 stubs/hmp-cmds-target-i386.c
 rename stubs/{monitor-arm-gic.c => qmp-arm-gic.c} (100%)
 rename stubs/{monitor-cpu-s390x-kvm.c => qmp-cpu-s390x-kvm.c} (100%)
 rename stubs/{monitor-cpu-s390x.c => qmp-cpu-s390x.c} (100%)
 rename stubs/{monitor-cpu.c => qmp-cpu.c} (100%)
 rename stubs/{monitor-i386-rtc.c => qmp-i386-rtc.c} (100%)
 rename stubs/{monitor-i386-sev.c => qmp-i386-sev.c} (100%)
 rename stubs/{monitor-i386-sgx.c => qmp-i386-sgx.c} (100%)
 rename stubs/{monitor-i386-xen.c => qmp-i386-xen.c} (100%)
 delete mode 100644 stubs/target-get-monitor-def.c
 delete mode 100644 stubs/target-monitor-defs.c

-- 
2.53.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v2 01/27] monitor: Have MonitorDef::get_value() always return int64_t type
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
@ 2026-04-10 19:52 ` Philippe Mathieu-Daudé
  2026-04-13  2:42   ` Richard Henderson
  2026-04-10 19:52 ` [PATCH v2 02/27] monitor: Remove target_long use in get_monitor_def() Philippe Mathieu-Daudé
                   ` (25 subsequent siblings)
  26 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Paolo Bonzini, Zhao Liu

Simplify MonitorDef::get_value() handler by having it always
return a int64_t type. Truncate to 32-bit in the single caller.

Note, this handler is only implemented once for the x86 targets.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/monitor/hmp-target.h | 6 +-----
 monitor/hmp-target.c         | 4 +++-
 target/i386/monitor.c        | 4 ++--
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/include/monitor/hmp-target.h b/include/monitor/hmp-target.h
index ce0bb1983cc..6364c94edf8 100644
--- a/include/monitor/hmp-target.h
+++ b/include/monitor/hmp-target.h
@@ -27,15 +27,11 @@
 
 typedef struct MonitorDef MonitorDef;
 
-#ifdef COMPILING_PER_TARGET
-#include "exec/target_long.h"
 struct MonitorDef {
     const char *name;
     int offset;
-    target_long (*get_value)(Monitor *mon, const struct MonitorDef *md,
-                             int val);
+    int64_t (*get_value)(Monitor *mon, const struct MonitorDef *md, int offset);
 };
-#endif
 
 const MonitorDef *target_monitor_defs(void);
 int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval);
diff --git a/monitor/hmp-target.c b/monitor/hmp-target.c
index da7dd7f31f2..812714ada01 100644
--- a/monitor/hmp-target.c
+++ b/monitor/hmp-target.c
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/target-info.h"
 #include "monitor-internal.h"
 #include "monitor/qdev.h"
 #include "net/slirp.h"
@@ -79,7 +80,8 @@ int get_monitor_def(Monitor *mon, int64_t *pval, const char *name)
     for(; md->name != NULL; md++) {
         if (hmp_compare_cmd(name, md->name)) {
             if (md->get_value) {
-                *pval = md->get_value(mon, md, md->offset);
+                int64_t val = md->get_value(mon, md, md->offset);
+                *pval = target_long_bits() == 32 ? (int32_t)val : val;
             } else {
                 CPUArchState *env = mon_get_cpu_env(mon);
                 ptr = (uint8_t *)env + md->offset;
diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index 977f65fe16c..b128334e571 100644
--- a/target/i386/monitor.c
+++ b/target/i386/monitor.c
@@ -593,8 +593,8 @@ void hmp_mce(Monitor *mon, const QDict *qdict)
     }
 }
 
-static target_long monitor_get_pc(Monitor *mon, const struct MonitorDef *md,
-                                  int val)
+static int64_t monitor_get_pc(Monitor *mon, const struct MonitorDef *md,
+                              int offset)
 {
     CPUArchState *env = mon_get_cpu_env(mon);
     return env->eip + env->segs[R_CS].base;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 02/27] monitor: Remove target_long use in get_monitor_def()
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
  2026-04-10 19:52 ` [PATCH v2 01/27] monitor: Have MonitorDef::get_value() always return int64_t type Philippe Mathieu-Daudé
@ 2026-04-10 19:52 ` Philippe Mathieu-Daudé
  2026-04-13  2:54   ` Richard Henderson
  2026-04-10 19:52 ` [PATCH v2 03/27] monitor: Reduce target-specific methods further Philippe Mathieu-Daudé
                   ` (24 subsequent siblings)
  26 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé

Truncate manually, removing the need of target-specific
code in get_monitor_def().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 monitor/hmp-target.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/monitor/hmp-target.c b/monitor/hmp-target.c
index 812714ada01..b9b79e8e927 100644
--- a/monitor/hmp-target.c
+++ b/monitor/hmp-target.c
@@ -93,7 +93,7 @@ int get_monitor_def(Monitor *mon, int64_t *pval, const char *name)
 
     ret = target_get_monitor_def(cs, name, &tmp);
     if (!ret) {
-        *pval = (target_long) tmp;
+        *pval = target_long_bits() == 32 ? (int32_t)tmp : tmp;
     }
 
     return ret;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 03/27] monitor: Reduce target-specific methods further
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
  2026-04-10 19:52 ` [PATCH v2 01/27] monitor: Have MonitorDef::get_value() always return int64_t type Philippe Mathieu-Daudé
  2026-04-10 19:52 ` [PATCH v2 02/27] monitor: Remove target_long use in get_monitor_def() Philippe Mathieu-Daudé
@ 2026-04-10 19:52 ` Philippe Mathieu-Daudé
  2026-04-13  2:54   ` Richard Henderson
  2026-04-10 19:52 ` [PATCH v2 04/27] monitor: Remove 'monitor/hmp-target.h' header Philippe Mathieu-Daudé
                   ` (23 subsequent siblings)
  26 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé

get_monitor_def() doesn't use any target-specific declaration
anymore, move it to hmp.c to compile it once.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>
---
 monitor/monitor-internal.h |  1 -
 monitor/hmp-target.c       | 39 -------------------------------------
 monitor/hmp.c              | 40 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
index feca111ae31..3ecd394ecf6 100644
--- a/monitor/monitor-internal.h
+++ b/monitor/monitor-internal.h
@@ -181,7 +181,6 @@ void monitor_data_destroy_qmp(MonitorQMP *mon);
 void coroutine_fn monitor_qmp_dispatcher_co(void *data);
 void qmp_dispatcher_co_wake(void);
 
-int get_monitor_def(Monitor *mon, int64_t *pval, const char *name);
 void handle_hmp_command(MonitorHMP *mon, const char *cmdline);
 int hmp_compare_cmd(const char *name, const char *list);
 
diff --git a/monitor/hmp-target.c b/monitor/hmp-target.c
index b9b79e8e927..c840ae5f0a2 100644
--- a/monitor/hmp-target.c
+++ b/monitor/hmp-target.c
@@ -23,7 +23,6 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu/target-info.h"
 #include "monitor-internal.h"
 #include "monitor/qdev.h"
 #include "net/slirp.h"
@@ -61,44 +60,6 @@ HMPCommand *hmp_cmds_for_target(bool info_command)
     return info_command ? hmp_info_cmds : hmp_cmds;
 }
 
-/*
- * Set @pval to the value in the register identified by @name.
- * return 0 if OK, -1 if not found
- */
-int get_monitor_def(Monitor *mon, int64_t *pval, const char *name)
-{
-    const MonitorDef *md = target_monitor_defs();
-    CPUState *cs = mon_get_cpu(mon);
-    void *ptr;
-    uint64_t tmp = 0;
-    int ret;
-
-    if (cs == NULL || md == NULL) {
-        return -1;
-    }
-
-    for(; md->name != NULL; md++) {
-        if (hmp_compare_cmd(name, md->name)) {
-            if (md->get_value) {
-                int64_t val = md->get_value(mon, md, md->offset);
-                *pval = target_long_bits() == 32 ? (int32_t)val : val;
-            } else {
-                CPUArchState *env = mon_get_cpu_env(mon);
-                ptr = (uint8_t *)env + md->offset;
-                *pval = *(int32_t *)ptr;
-            }
-            return 0;
-        }
-    }
-
-    ret = target_get_monitor_def(cs, name, &tmp);
-    if (!ret) {
-        *pval = target_long_bits() == 32 ? (int32_t)tmp : tmp;
-    }
-
-    return ret;
-}
-
 static int
 compare_mon_cmd(const void *a, const void *b)
 {
diff --git a/monitor/hmp.c b/monitor/hmp.c
index 0e5913fabb1..20ba1e62988 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -355,6 +355,8 @@ static bool gdb_get_register(Monitor *mon, int64_t *pval, const char *name)
 static const char *pch;
 static sigjmp_buf expr_env;
 
+static int get_monitor_def(Monitor *mon, int64_t *pval, const char *name);
+
 static G_NORETURN G_GNUC_PRINTF(2, 3)
 void expr_error(Monitor *mon, const char *fmt, ...)
 {
@@ -1595,3 +1597,41 @@ void monitor_register_hmp_info_hrt(const char *name,
     }
     g_assert_not_reached();
 }
+
+/*
+ * Set @pval to the value in the register identified by @name.
+ * return 0 if OK, -1 if not found
+ */
+static int get_monitor_def(Monitor *mon, int64_t *pval, const char *name)
+{
+    const MonitorDef *md = target_monitor_defs();
+    CPUState *cs = mon_get_cpu(mon);
+    void *ptr;
+    uint64_t tmp = 0;
+    int ret;
+
+    if (cs == NULL || md == NULL) {
+        return -1;
+    }
+
+    for (; md->name != NULL; md++) {
+        if (hmp_compare_cmd(name, md->name)) {
+            if (md->get_value) {
+                int64_t val = md->get_value(mon, md, md->offset);
+                *pval = target_long_bits() == 32 ? (int32_t)val : val;
+            } else {
+                CPUArchState *env = mon_get_cpu_env(mon);
+                ptr = (uint8_t *)env + md->offset;
+                *pval = *(int32_t *)ptr;
+            }
+            return 0;
+        }
+    }
+
+    ret = target_get_monitor_def(cs, name, &tmp);
+    if (!ret) {
+        *pval = target_long_bits() == 32 ? (int32_t)tmp : tmp;
+    }
+
+    return ret;
+}
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 04/27] monitor: Remove 'monitor/hmp-target.h' header
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2026-04-10 19:52 ` [PATCH v2 03/27] monitor: Reduce target-specific methods further Philippe Mathieu-Daudé
@ 2026-04-10 19:52 ` Philippe Mathieu-Daudé
  2026-04-10 19:52 ` [PATCH v2 05/27] monitor: Forward-declare the MonitorDef type Philippe Mathieu-Daudé
                   ` (22 subsequent siblings)
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Paolo Bonzini, Marcelo Tosatti,
	Michael S. Tsirkin, Marcel Apfelbaum, Zhao Liu, Laurent Vivier,
	Nicholas Piggin, Chinmay Rath, Glenn Miles, Palmer Dabbelt,
	Alistair Francis, Weiwei Li, Daniel Henrique Barboza, Liu Zhiwei,
	Chao Liu, Yoshinori Sato, Mark Cave-Ayland, Artyom Tarasenko,
	Max Filippov

The "monitor/hmp-target.h" header doesn't contain any
target-specific declarations anymore. Merge it with
"monitor/hmp.h", its target-agnostic counterpart.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>
---
 MAINTAINERS                   |  1 -
 include/monitor/hmp-target.h  | 42 -----------------------------------
 include/monitor/hmp.h         | 12 ++++++++++
 hw/i386/sgx-stub.c            |  1 -
 hw/i386/sgx.c                 |  1 -
 monitor/hmp-cmds.c            |  1 -
 monitor/hmp-target.c          |  1 -
 monitor/hmp.c                 |  1 -
 stubs/target-monitor-defs.c   |  2 +-
 target/i386/cpu-apic.c        |  1 -
 target/i386/monitor.c         |  1 -
 target/i386/sev-system-stub.c |  1 -
 target/i386/sev.c             |  1 -
 target/m68k/monitor.c         |  1 -
 target/ppc/monitor.c          |  2 --
 target/riscv/monitor.c        |  1 -
 target/sh4/monitor.c          |  1 -
 target/sparc/monitor.c        |  1 -
 target/xtensa/monitor.c       |  1 -
 19 files changed, 13 insertions(+), 60 deletions(-)
 delete mode 100644 include/monitor/hmp-target.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 535d1d3398e..edbbd544d62 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3411,7 +3411,6 @@ F: hmp.h
 F: hmp-commands*.hx
 F: include/monitor/hmp.h
 F: include/monitor/hmp-completion.h
-F: include/monitor/hmp-target.h
 F: tests/qtest/test-hmp.c
 F: include/qemu/qemu-print.h
 F: util/qemu-print.c
diff --git a/include/monitor/hmp-target.h b/include/monitor/hmp-target.h
deleted file mode 100644
index 6364c94edf8..00000000000
--- a/include/monitor/hmp-target.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * QEMU monitor
- *
- * Copyright (c) 2003-2004 Fabrice Bellard
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#ifndef MONITOR_HMP_TARGET_H
-#define MONITOR_HMP_TARGET_H
-
-typedef struct MonitorDef MonitorDef;
-
-struct MonitorDef {
-    const char *name;
-    int offset;
-    int64_t (*get_value)(Monitor *mon, const struct MonitorDef *md, int offset);
-};
-
-const MonitorDef *target_monitor_defs(void);
-int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval);
-
-CPUArchState *mon_get_cpu_env(Monitor *mon);
-CPUState *mon_get_cpu(Monitor *mon);
-
-#endif /* MONITOR_HMP_TARGET_H */
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index 9c2330205fc..f17a50a3fed 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -17,6 +17,18 @@
 #include "qemu/readline.h"
 #include "qapi/qapi-types-common.h"
 
+typedef struct MonitorDef {
+    const char *name;
+    int offset;
+    int64_t (*get_value)(Monitor *mon, const struct MonitorDef *md, int offset);
+} MonitorDef;
+
+const MonitorDef *target_monitor_defs(void);
+int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval);
+
+CPUArchState *mon_get_cpu_env(Monitor *mon);
+CPUState *mon_get_cpu(Monitor *mon);
+
 bool hmp_handle_error(Monitor *mon, Error *err);
 void hmp_help_cmd(Monitor *mon, const char *name);
 strList *hmp_split_at_comma(const char *str);
diff --git a/hw/i386/sgx-stub.c b/hw/i386/sgx-stub.c
index 1dd8d9afbfa..6e82773a86d 100644
--- a/hw/i386/sgx-stub.c
+++ b/hw/i386/sgx-stub.c
@@ -1,7 +1,6 @@
 #include "qemu/osdep.h"
 #include "monitor/monitor.h"
 #include "monitor/hmp.h"
-#include "monitor/hmp-target.h"
 #include "hw/i386/pc.h"
 #include "hw/i386/sgx-epc.h"
 #include "qapi/qapi-commands-misc-i386.h"
diff --git a/hw/i386/sgx.c b/hw/i386/sgx.c
index 5e792e8e6e9..7e4c509f5a4 100644
--- a/hw/i386/sgx.c
+++ b/hw/i386/sgx.c
@@ -17,7 +17,6 @@
 #include "monitor/qdev.h"
 #include "monitor/monitor.h"
 #include "monitor/hmp.h"
-#include "monitor/hmp-target.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "qapi/qapi-commands-misc-i386.h"
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index bc26b39d708..e81632f5551 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -22,7 +22,6 @@
 #include "monitor/hmp.h"
 #include "qemu/help_option.h"
 #include "monitor/hmp.h"
-#include "monitor/hmp-target.h"
 #include "monitor/monitor-internal.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-control.h"
diff --git a/monitor/hmp-target.c b/monitor/hmp-target.c
index c840ae5f0a2..d07e545ef7e 100644
--- a/monitor/hmp-target.c
+++ b/monitor/hmp-target.c
@@ -27,7 +27,6 @@
 #include "monitor/qdev.h"
 #include "net/slirp.h"
 #include "system/device_tree.h"
-#include "monitor/hmp-target.h"
 #include "monitor/hmp.h"
 #include "monitor/hmp-completion.h"
 #include "block/block-hmp-cmds.h"
diff --git a/monitor/hmp.c b/monitor/hmp.c
index 20ba1e62988..983048db1b9 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -27,7 +27,6 @@
 #include "hw/core/qdev.h"
 #include "monitor-internal.h"
 #include "monitor/hmp.h"
-#include "monitor/hmp-target.h"
 #include "qobject/qdict.h"
 #include "qobject/qnum.h"
 #include "qemu/bswap.h"
diff --git a/stubs/target-monitor-defs.c b/stubs/target-monitor-defs.c
index 35a0a342772..0dd4cdb34f6 100644
--- a/stubs/target-monitor-defs.c
+++ b/stubs/target-monitor-defs.c
@@ -1,5 +1,5 @@
 #include "qemu/osdep.h"
-#include "monitor/hmp-target.h"
+#include "monitor/hmp.h"
 
 const MonitorDef *target_monitor_defs(void)
 {
diff --git a/target/i386/cpu-apic.c b/target/i386/cpu-apic.c
index eaa10ad2a3d..5599a4675c5 100644
--- a/target/i386/cpu-apic.c
+++ b/target/i386/cpu-apic.c
@@ -11,7 +11,6 @@
 #include "qapi/error.h"
 #include "monitor/monitor.h"
 #include "monitor/hmp.h"
-#include "monitor/hmp-target.h"
 #include "system/hw_accel.h"
 #include "system/kvm.h"
 #include "system/xen.h"
diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index b128334e571..ddc666d3451 100644
--- a/target/i386/monitor.c
+++ b/target/i386/monitor.c
@@ -25,7 +25,6 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "monitor/monitor.h"
-#include "monitor/hmp-target.h"
 #include "monitor/hmp.h"
 #include "qobject/qdict.h"
 #include "qapi/error.h"
diff --git a/target/i386/sev-system-stub.c b/target/i386/sev-system-stub.c
index fb84aee94d2..f799a338d60 100644
--- a/target/i386/sev-system-stub.c
+++ b/target/i386/sev-system-stub.c
@@ -14,7 +14,6 @@
 #include "qemu/osdep.h"
 #include "monitor/monitor.h"
 #include "monitor/hmp.h"
-#include "monitor/hmp-target.h"
 #include "qapi/error.h"
 #include "sev.h"
 
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 9dde972c118..97e745f27c4 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -39,7 +39,6 @@
 #include "qom/object.h"
 #include "monitor/monitor.h"
 #include "monitor/hmp.h"
-#include "monitor/hmp-target.h"
 #include "qapi/qapi-commands-misc-i386.h"
 #include "confidential-guest.h"
 #include "hw/i386/pc.h"
diff --git a/target/m68k/monitor.c b/target/m68k/monitor.c
index 94bb12833af..be7411edca6 100644
--- a/target/m68k/monitor.c
+++ b/target/m68k/monitor.c
@@ -8,7 +8,6 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "monitor/hmp.h"
-#include "monitor/hmp-target.h"
 #include "monitor/monitor.h"
 
 void hmp_info_tlb(Monitor *mon, const QDict *qdict)
diff --git a/target/ppc/monitor.c b/target/ppc/monitor.c
index 776a76602ea..7c88e0e2bda 100644
--- a/target/ppc/monitor.c
+++ b/target/ppc/monitor.c
@@ -7,9 +7,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu/ctype.h"
 #include "monitor/monitor.h"
-#include "monitor/hmp-target.h"
 #include "monitor/hmp.h"
 #include "cpu.h"
 
diff --git a/target/riscv/monitor.c b/target/riscv/monitor.c
index a9d31114442..3f206b9fca5 100644
--- a/target/riscv/monitor.c
+++ b/target/riscv/monitor.c
@@ -25,7 +25,6 @@
 #include "cpu_bits.h"
 #include "monitor/monitor.h"
 #include "monitor/hmp.h"
-#include "monitor/hmp-target.h"
 #include "system/memory.h"
 
 #ifdef TARGET_RISCV64
diff --git a/target/sh4/monitor.c b/target/sh4/monitor.c
index 2da6a5426eb..50324d3600c 100644
--- a/target/sh4/monitor.c
+++ b/target/sh4/monitor.c
@@ -24,7 +24,6 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "monitor/monitor.h"
-#include "monitor/hmp-target.h"
 #include "monitor/hmp.h"
 
 static void print_tlb(Monitor *mon, int idx, tlb_t *tlb)
diff --git a/target/sparc/monitor.c b/target/sparc/monitor.c
index a60671a60a4..99abddbf1e0 100644
--- a/target/sparc/monitor.c
+++ b/target/sparc/monitor.c
@@ -24,7 +24,6 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "monitor/monitor.h"
-#include "monitor/hmp-target.h"
 #include "monitor/hmp.h"
 
 
diff --git a/target/xtensa/monitor.c b/target/xtensa/monitor.c
index fbf60d55530..2af84934f83 100644
--- a/target/xtensa/monitor.c
+++ b/target/xtensa/monitor.c
@@ -24,7 +24,6 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "monitor/monitor.h"
-#include "monitor/hmp-target.h"
 #include "monitor/hmp.h"
 
 void hmp_info_tlb(Monitor *mon, const QDict *qdict)
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 05/27] monitor: Forward-declare the MonitorDef type
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2026-04-10 19:52 ` [PATCH v2 04/27] monitor: Remove 'monitor/hmp-target.h' header Philippe Mathieu-Daudé
@ 2026-04-10 19:52 ` Philippe Mathieu-Daudé
  2026-04-13  3:10   ` Richard Henderson
  2026-04-10 19:53 ` [PATCH v2 06/27] cpus: Introduce SysemuCPUOps::monitor_defs hook Philippe Mathieu-Daudé
                   ` (21 subsequent siblings)
  26 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé

Rather than having core header forced to include "monitor/hmp.h"
to get the MonitorDef type declaration, forward-declare it in
"qemu/typedefs.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/monitor/hmp.h   | 6 +++---
 include/qemu/typedefs.h | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index f17a50a3fed..516089eb5c6 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -17,11 +17,11 @@
 #include "qemu/readline.h"
 #include "qapi/qapi-types-common.h"
 
-typedef struct MonitorDef {
+struct MonitorDef {
     const char *name;
     int offset;
-    int64_t (*get_value)(Monitor *mon, const struct MonitorDef *md, int offset);
-} MonitorDef;
+    int64_t (*get_value)(Monitor *mon, const MonitorDef *md, int offset);
+};
 
 const MonitorDef *target_monitor_defs(void);
 int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval);
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 416a8c9acea..07f2ae7c9f1 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -72,6 +72,7 @@ typedef struct MemoryRegionSection MemoryRegionSection;
 typedef struct MigrationIncomingState MigrationIncomingState;
 typedef struct MigrationState MigrationState;
 typedef struct Monitor Monitor;
+typedef struct MonitorDef MonitorDef;
 typedef struct MSIMessage MSIMessage;
 typedef struct NetClientState NetClientState;
 typedef struct NetFilterState NetFilterState;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 06/27] cpus: Introduce SysemuCPUOps::monitor_defs hook
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2026-04-10 19:52 ` [PATCH v2 05/27] monitor: Forward-declare the MonitorDef type Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 07/27] target/i386: Replace target_monitor_defs -> SysemuCPUOps::monitor_defs Philippe Mathieu-Daudé
                   ` (20 subsequent siblings)
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé

Allow targets to register their legacy target_monitor_defs()
in SysemuCPUOps; check it first in get_monitor_def() otherwise
fall back to previous per-target helper.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/core/sysemu-cpu-ops.h | 5 +++++
 monitor/hmp.c                    | 9 +++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/hw/core/sysemu-cpu-ops.h b/include/hw/core/sysemu-cpu-ops.h
index 7b2d2d2610f..a96f4907d05 100644
--- a/include/hw/core/sysemu-cpu-ops.h
+++ b/include/hw/core/sysemu-cpu-ops.h
@@ -85,6 +85,11 @@ typedef struct SysemuCPUOps {
      */
     bool (*internal_is_big_endian)(CPUState *cpu);
 
+    /**
+     * @monitor_defs: Array of MonitorDef entries. This field is legacy,
+     *                use @gdb_core_xml_file to dump registers instead.
+     */
+    const MonitorDef *monitor_defs;
     /**
      * @legacy_vmsd: Legacy state for migration.
      *               Do not use in new targets, use #DeviceClass::vmsd instead.
diff --git a/monitor/hmp.c b/monitor/hmp.c
index 983048db1b9..6cf2f3e65ff 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -25,6 +25,7 @@
 #include "qemu/osdep.h"
 #include <dirent.h>
 #include "hw/core/qdev.h"
+#include "hw/core/sysemu-cpu-ops.h"
 #include "monitor-internal.h"
 #include "monitor/hmp.h"
 #include "qobject/qdict.h"
@@ -1603,13 +1604,17 @@ void monitor_register_hmp_info_hrt(const char *name,
  */
 static int get_monitor_def(Monitor *mon, int64_t *pval, const char *name)
 {
-    const MonitorDef *md = target_monitor_defs();
     CPUState *cs = mon_get_cpu(mon);
+    const MonitorDef *md;
     void *ptr;
     uint64_t tmp = 0;
     int ret;
 
-    if (cs == NULL || md == NULL) {
+    if (cs == NULL) {
+        return -1;
+    }
+    md = cs->cc->sysemu_ops->monitor_defs ?: target_monitor_defs();
+    if (md == NULL) {
         return -1;
     }
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 07/27] target/i386: Replace target_monitor_defs -> SysemuCPUOps::monitor_defs
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 06/27] cpus: Introduce SysemuCPUOps::monitor_defs hook Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 08/27] target/m68k: " Philippe Mathieu-Daudé
                   ` (19 subsequent siblings)
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Paolo Bonzini, Zhao Liu

Restrict x86_monitor_defs[] to cpu.c, register it as
SysemuCPUOps::monitor_defs hook, allowing to remove
the target_monitor_defs() method.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/i386/cpu.c     | 24 ++++++++++++++++++++++++
 target/i386/monitor.c | 25 -------------------------
 2 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index c6fd1dc00eb..968414e7215 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -39,6 +39,7 @@
 #include "exec/watchpoint.h"
 #ifndef CONFIG_USER_ONLY
 #include "confidential-guest.h"
+#include "monitor/hmp.h"
 #include "system/reset.h"
 #include "qapi/qapi-commands-machine.h"
 #include "system/address-spaces.h"
@@ -10685,6 +10686,28 @@ static const Property x86_cpu_properties[] = {
 };
 
 #ifndef CONFIG_USER_ONLY
+
+static int64_t monitor_get_pc(Monitor *mon, const struct MonitorDef *md,
+                              int offset)
+{
+    CPUArchState *env = mon_get_cpu_env(mon);
+    return env->eip + env->segs[R_CS].base;
+}
+
+static const MonitorDef x86_monitor_defs[] = {
+#define SEG(name, seg) \
+    { name ".limit", offsetof(CPUX86State, segs[seg].limit) },
+    SEG("cs", R_CS)
+    SEG("ds", R_DS)
+    SEG("es", R_ES)
+    SEG("ss", R_SS)
+    SEG("fs", R_FS)
+    SEG("gs", R_GS)
+    { "pc", 0, monitor_get_pc, },
+    { NULL },
+#undef SEG
+};
+
 #include "hw/core/sysemu-cpu-ops.h"
 
 static const struct SysemuCPUOps i386_sysemu_ops = {
@@ -10698,6 +10721,7 @@ static const struct SysemuCPUOps i386_sysemu_ops = {
     .write_elf64_note = x86_cpu_write_elf64_note,
     .write_elf32_qemunote = x86_cpu_write_elf32_qemunote,
     .write_elf64_qemunote = x86_cpu_write_elf64_qemunote,
+    .monitor_defs = x86_monitor_defs,
     .legacy_vmsd = &vmstate_x86_cpu,
 };
 #endif
diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index ddc666d3451..a536712c755 100644
--- a/target/i386/monitor.c
+++ b/target/i386/monitor.c
@@ -591,28 +591,3 @@ void hmp_mce(Monitor *mon, const QDict *qdict)
                            flags);
     }
 }
-
-static int64_t monitor_get_pc(Monitor *mon, const struct MonitorDef *md,
-                              int offset)
-{
-    CPUArchState *env = mon_get_cpu_env(mon);
-    return env->eip + env->segs[R_CS].base;
-}
-
-const MonitorDef monitor_defs[] = {
-#define SEG(name, seg) \
-    { name ".limit", offsetof(CPUX86State, segs[seg].limit) },
-    SEG("cs", R_CS)
-    SEG("ds", R_DS)
-    SEG("es", R_ES)
-    SEG("ss", R_SS)
-    SEG("fs", R_FS)
-    SEG("gs", R_GS)
-    { "pc", 0, monitor_get_pc, },
-    { NULL },
-};
-
-const MonitorDef *target_monitor_defs(void)
-{
-    return monitor_defs;
-}
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 08/27] target/m68k: Replace target_monitor_defs -> SysemuCPUOps::monitor_defs
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 07/27] target/i386: Replace target_monitor_defs -> SysemuCPUOps::monitor_defs Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-13  3:59   ` Richard Henderson
  2026-04-10 19:53 ` [PATCH v2 09/27] target/sparc: " Philippe Mathieu-Daudé
                   ` (18 subsequent siblings)
  26 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Laurent Vivier

Restrict m68k_monitor_defs[] to cpu.c, register it as
SysemuCPUOps::monitor_defs hook, allowing to remove
the target_monitor_defs() method.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/m68k/cpu.c     | 18 ++++++++++++++++++
 target/m68k/monitor.c | 21 ---------------------
 2 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
index d849a4a90fc..f704a6af613 100644
--- a/target/m68k/cpu.c
+++ b/target/m68k/cpu.c
@@ -25,6 +25,7 @@
 
 #ifndef CONFIG_USER_ONLY
 #include "migration/vmstate.h"
+#include "monitor/hmp.h"
 #endif
 
 #include "cpu.h"
@@ -602,11 +603,28 @@ static const VMStateDescription vmstate_m68k_cpu = {
     },
 };
 
+static const MonitorDef m68k_monitor_defs[] = {
+    { "ssp", offsetof(CPUM68KState, sp[0]) },
+    { "usp", offsetof(CPUM68KState, sp[1]) },
+    { "isp", offsetof(CPUM68KState, sp[2]) },
+    { "sfc", offsetof(CPUM68KState, sfc) },
+    { "dfc", offsetof(CPUM68KState, dfc) },
+    { "urp", offsetof(CPUM68KState, mmu.urp) },
+    { "srp", offsetof(CPUM68KState, mmu.srp) },
+    { "dttr0", offsetof(CPUM68KState, mmu.ttr[M68K_DTTR0]) },
+    { "dttr1", offsetof(CPUM68KState, mmu.ttr[M68K_DTTR1]) },
+    { "ittr0", offsetof(CPUM68KState, mmu.ttr[M68K_ITTR0]) },
+    { "ittr1", offsetof(CPUM68KState, mmu.ttr[M68K_ITTR1]) },
+    { "mmusr", offsetof(CPUM68KState, mmu.mmusr) },
+    { NULL },
+};
+
 #include "hw/core/sysemu-cpu-ops.h"
 
 static const struct SysemuCPUOps m68k_sysemu_ops = {
     .has_work = m68k_cpu_has_work,
     .get_phys_page_debug = m68k_cpu_get_phys_page_debug,
+    .monitor_defs = m68k_monitor_defs,
 };
 #endif /* !CONFIG_USER_ONLY */
 
diff --git a/target/m68k/monitor.c b/target/m68k/monitor.c
index be7411edca6..3e0df40a6b8 100644
--- a/target/m68k/monitor.c
+++ b/target/m68k/monitor.c
@@ -21,24 +21,3 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)
 
     dump_mmu(env1);
 }
-
-static const MonitorDef monitor_defs[] = {
-    { "ssp", offsetof(CPUM68KState, sp[0]) },
-    { "usp", offsetof(CPUM68KState, sp[1]) },
-    { "isp", offsetof(CPUM68KState, sp[2]) },
-    { "sfc", offsetof(CPUM68KState, sfc) },
-    { "dfc", offsetof(CPUM68KState, dfc) },
-    { "urp", offsetof(CPUM68KState, mmu.urp) },
-    { "srp", offsetof(CPUM68KState, mmu.srp) },
-    { "dttr0", offsetof(CPUM68KState, mmu.ttr[M68K_DTTR0]) },
-    { "dttr1", offsetof(CPUM68KState, mmu.ttr[M68K_DTTR1]) },
-    { "ittr0", offsetof(CPUM68KState, mmu.ttr[M68K_ITTR0]) },
-    { "ittr1", offsetof(CPUM68KState, mmu.ttr[M68K_ITTR1]) },
-    { "mmusr", offsetof(CPUM68KState, mmu.mmusr) },
-    { NULL },
-};
-
-const MonitorDef *target_monitor_defs(void)
-{
-    return monitor_defs;
-}
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 09/27] target/sparc: Replace target_monitor_defs -> SysemuCPUOps::monitor_defs
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 08/27] target/m68k: " Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 10/27] monitor: Remove target_monitor_defs() Philippe Mathieu-Daudé
                   ` (17 subsequent siblings)
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Mark Cave-Ayland, Artyom Tarasenko

Restrict sparc64_monitor_defs[] to cpu.c, register it
as SysemuCPUOps::monitor_defs hook (taking care to not
register it on 32-bit SPARC target), allowing to remove
the target_monitor_defs() method.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/sparc/cpu.c     | 19 +++++++++++++++++++
 target/sparc/monitor.c | 18 ------------------
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index 1493336e7a2..9c5175aca34 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -993,12 +993,31 @@ static const Property sparc_cpu_properties[] = {
 };
 
 #ifndef CONFIG_USER_ONLY
+
+#ifdef TARGET_SPARC64
+#include "monitor/hmp.h"
+
+static const MonitorDef sparc64_monitor_defs[] = {
+    { "asi", offsetof(CPUSPARCState, asi) },
+    { "pstate", offsetof(CPUSPARCState, pstate) },
+    { "cansave", offsetof(CPUSPARCState, cansave) },
+    { "canrestore", offsetof(CPUSPARCState, canrestore) },
+    { "otherwin", offsetof(CPUSPARCState, otherwin) },
+    { "wstate", offsetof(CPUSPARCState, wstate) },
+    { "cleanwin", offsetof(CPUSPARCState, cleanwin) },
+    { NULL },
+};
+#endif
+
 #include "hw/core/sysemu-cpu-ops.h"
 
 static const struct SysemuCPUOps sparc_sysemu_ops = {
     .has_work = sparc_cpu_has_work,
     .get_phys_page_debug = sparc_cpu_get_phys_page_debug,
     .legacy_vmsd = &vmstate_sparc_cpu,
+#if defined(TARGET_SPARC64)
+    .monitor_defs = sparc64_monitor_defs,
+#endif
 };
 #endif
 
diff --git a/target/sparc/monitor.c b/target/sparc/monitor.c
index 99abddbf1e0..36f3d8d58e9 100644
--- a/target/sparc/monitor.c
+++ b/target/sparc/monitor.c
@@ -37,21 +37,3 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)
     }
     dump_mmu(env1);
 }
-
-const MonitorDef monitor_defs[] = {
-#ifdef TARGET_SPARC64
-    { "asi", offsetof(CPUSPARCState, asi) },
-    { "pstate", offsetof(CPUSPARCState, pstate) },
-    { "cansave", offsetof(CPUSPARCState, cansave) },
-    { "canrestore", offsetof(CPUSPARCState, canrestore) },
-    { "otherwin", offsetof(CPUSPARCState, otherwin) },
-    { "wstate", offsetof(CPUSPARCState, wstate) },
-    { "cleanwin", offsetof(CPUSPARCState, cleanwin) },
-#endif
-    { NULL },
-};
-
-const MonitorDef *target_monitor_defs(void)
-{
-    return monitor_defs;
-}
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 10/27] monitor: Remove target_monitor_defs()
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 09/27] target/sparc: " Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 11/27] cpus: Introduce SysemuCPUOps::monitor_get_register() hook Philippe Mathieu-Daudé
                   ` (16 subsequent siblings)
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Paolo Bonzini

target_monitor_defs() is now only a dead stub. Remove as pointless.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/monitor/hmp.h       | 1 -
 monitor/hmp.c               | 2 +-
 stubs/target-monitor-defs.c | 7 -------
 stubs/meson.build           | 1 -
 4 files changed, 1 insertion(+), 10 deletions(-)
 delete mode 100644 stubs/target-monitor-defs.c

diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index 516089eb5c6..cabb2c55f8e 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -23,7 +23,6 @@ struct MonitorDef {
     int64_t (*get_value)(Monitor *mon, const MonitorDef *md, int offset);
 };
 
-const MonitorDef *target_monitor_defs(void);
 int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval);
 
 CPUArchState *mon_get_cpu_env(Monitor *mon);
diff --git a/monitor/hmp.c b/monitor/hmp.c
index 6cf2f3e65ff..3d812ea3068 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -1613,7 +1613,7 @@ static int get_monitor_def(Monitor *mon, int64_t *pval, const char *name)
     if (cs == NULL) {
         return -1;
     }
-    md = cs->cc->sysemu_ops->monitor_defs ?: target_monitor_defs();
+    md = cs->cc->sysemu_ops->monitor_defs;
     if (md == NULL) {
         return -1;
     }
diff --git a/stubs/target-monitor-defs.c b/stubs/target-monitor-defs.c
deleted file mode 100644
index 0dd4cdb34f6..00000000000
--- a/stubs/target-monitor-defs.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "qemu/osdep.h"
-#include "monitor/hmp.h"
-
-const MonitorDef *target_monitor_defs(void)
-{
-    return NULL;
-}
diff --git a/stubs/meson.build b/stubs/meson.build
index 7189ff63ed5..10eb68ab55e 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -75,7 +75,6 @@ if have_system
   endif
   stub_ss.add(files('kvm.c'))
   stub_ss.add(files('target-get-monitor-def.c'))
-  stub_ss.add(files('target-monitor-defs.c'))
   stub_ss.add(files('win32-kbd-hook.c'))
   stub_ss.add(files('xen-hw-stub.c'))
   stub_ss.add(files('monitor-arm-gic.c'))
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 11/27] cpus: Introduce SysemuCPUOps::monitor_get_register() hook
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (9 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 10/27] monitor: Remove target_monitor_defs() Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-13  4:09   ` Richard Henderson
  2026-04-10 19:53 ` [PATCH v2 12/27] target/riscv: Register target_get_monitor_def in SysemuCPUOps Philippe Mathieu-Daudé
                   ` (15 subsequent siblings)
  26 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé

Allow targets to register their legacy target_get_monitor_def()
in SysemuCPUOps; check it first in get_monitor_def() otherwise
fall back to previous per-target helper.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/core/sysemu-cpu-ops.h | 8 ++++++++
 monitor/hmp.c                    | 6 +++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/hw/core/sysemu-cpu-ops.h b/include/hw/core/sysemu-cpu-ops.h
index a96f4907d05..a9200ec5737 100644
--- a/include/hw/core/sysemu-cpu-ops.h
+++ b/include/hw/core/sysemu-cpu-ops.h
@@ -85,11 +85,19 @@ typedef struct SysemuCPUOps {
      */
     bool (*internal_is_big_endian)(CPUState *cpu);
 
+    /**
+     * @monitor_get_register: Callback to fill @pval with register @name.
+     *                        This field is legacy, use @gdb_core_xml_file
+     *                        to dump registers instead.
+     */
+    int (*monitor_get_register)(CPUState *cs, const char *name, uint64_t *pval);
+
     /**
      * @monitor_defs: Array of MonitorDef entries. This field is legacy,
      *                use @gdb_core_xml_file to dump registers instead.
      */
     const MonitorDef *monitor_defs;
+
     /**
      * @legacy_vmsd: Legacy state for migration.
      *               Do not use in new targets, use #DeviceClass::vmsd instead.
diff --git a/monitor/hmp.c b/monitor/hmp.c
index 3d812ea3068..799855f3f68 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -1632,7 +1632,11 @@ static int get_monitor_def(Monitor *mon, int64_t *pval, const char *name)
         }
     }
 
-    ret = target_get_monitor_def(cs, name, &tmp);
+    if (cs->cc->sysemu_ops->monitor_get_register) {
+        ret = cs->cc->sysemu_ops->monitor_get_register(cs, name, &tmp);
+    } else {
+        ret = target_get_monitor_def(cs, name, &tmp);
+    }
     if (!ret) {
         *pval = target_long_bits() == 32 ? (int32_t)tmp : tmp;
     }
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 12/27] target/riscv: Register target_get_monitor_def in SysemuCPUOps
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (10 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 11/27] cpus: Introduce SysemuCPUOps::monitor_get_register() hook Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 13/27] monitor: Remove target_get_monitor_def() Philippe Mathieu-Daudé
                   ` (14 subsequent siblings)
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Palmer Dabbelt, Alistair Francis,
	Weiwei Li, Daniel Henrique Barboza, Liu Zhiwei, Chao Liu

Rename target_get_monitor_def() as riscv_monitor_get_register_legacy()
and register it as SysemuCPUOps::monitor_get_register() handler.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/riscv/internals.h | 3 +++
 target/riscv/cpu.c       | 1 +
 target/riscv/monitor.c   | 4 +++-
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/target/riscv/internals.h b/target/riscv/internals.h
index 35b923c4bf5..7c91f1872b6 100644
--- a/target/riscv/internals.h
+++ b/target/riscv/internals.h
@@ -233,4 +233,7 @@ static inline int insn_len(uint16_t first_word)
     return (first_word & 3) == 3 ? 4 : 2;
 }
 
+int riscv_monitor_get_register_legacy(CPUState *cs, const char *name,
+                                      uint64_t *pval);
+
 #endif
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 8ac935ac06e..dbd88fa6655 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -2720,6 +2720,7 @@ static const struct SysemuCPUOps riscv_sysemu_ops = {
     .get_phys_page_debug = riscv_cpu_get_phys_page_debug,
     .write_elf64_note = riscv_cpu_write_elf64_note,
     .write_elf32_note = riscv_cpu_write_elf32_note,
+    .monitor_get_register = riscv_monitor_get_register_legacy,
     .legacy_vmsd = &vmstate_riscv_cpu,
 };
 #endif
diff --git a/target/riscv/monitor.c b/target/riscv/monitor.c
index 3f206b9fca5..1c90c779534 100644
--- a/target/riscv/monitor.c
+++ b/target/riscv/monitor.c
@@ -26,6 +26,7 @@
 #include "monitor/monitor.h"
 #include "monitor/hmp.h"
 #include "system/memory.h"
+#include "internals.h"
 
 #ifdef TARGET_RISCV64
 #define PTE_HEADER_FIELDS       "vaddr            paddr            "\
@@ -310,7 +311,8 @@ static bool reg_is_vreg(const char *name)
     return false;
 }
 
-int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval)
+int riscv_monitor_get_register_legacy(CPUState *cs, const char *name,
+                                      uint64_t *pval)
 {
     CPURISCVState *env = &RISCV_CPU(cs)->env;
     target_ulong val = 0;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 13/27] monitor: Remove target_get_monitor_def()
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (11 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 12/27] target/riscv: Register target_get_monitor_def in SysemuCPUOps Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 14/27] monitor/meson: Use SPICE with migration HMP commands Philippe Mathieu-Daudé
                   ` (13 subsequent siblings)
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Paolo Bonzini

target_get_monitor_def() is now only a dead stub. Remove as pointless.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/monitor/hmp.h          |  2 --
 monitor/hmp.c                  |  7 +++----
 stubs/target-get-monitor-def.c | 29 -----------------------------
 stubs/meson.build              |  1 -
 4 files changed, 3 insertions(+), 36 deletions(-)
 delete mode 100644 stubs/target-get-monitor-def.c

diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index cabb2c55f8e..b444095f684 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -23,8 +23,6 @@ struct MonitorDef {
     int64_t (*get_value)(Monitor *mon, const MonitorDef *md, int offset);
 };
 
-int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval);
-
 CPUArchState *mon_get_cpu_env(Monitor *mon);
 CPUState *mon_get_cpu(Monitor *mon);
 
diff --git a/monitor/hmp.c b/monitor/hmp.c
index 799855f3f68..3b9e180c1ca 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -1632,11 +1632,10 @@ static int get_monitor_def(Monitor *mon, int64_t *pval, const char *name)
         }
     }
 
-    if (cs->cc->sysemu_ops->monitor_get_register) {
-        ret = cs->cc->sysemu_ops->monitor_get_register(cs, name, &tmp);
-    } else {
-        ret = target_get_monitor_def(cs, name, &tmp);
+    if (!cs->cc->sysemu_ops->monitor_get_register) {
+        return -1;
     }
+    ret = cs->cc->sysemu_ops->monitor_get_register(cs, name, &tmp);
     if (!ret) {
         *pval = target_long_bits() == 32 ? (int32_t)tmp : tmp;
     }
diff --git a/stubs/target-get-monitor-def.c b/stubs/target-get-monitor-def.c
deleted file mode 100644
index 394e0f9a7d2..00000000000
--- a/stubs/target-get-monitor-def.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- *  Stub for target_get_monitor_def.
- *
- *  Copyright IBM Corp., 2015
- *
- *  Author: Alexey Kardashevskiy <aik@ozlabs.ru>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License,
- *  or (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "qemu/osdep.h"
-
-int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval);
-
-int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval)
-{
-    return -1;
-}
diff --git a/stubs/meson.build b/stubs/meson.build
index 10eb68ab55e..85f9e3a4f23 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -74,7 +74,6 @@ if have_system
     stub_ss.add(files('igvm.c'))
   endif
   stub_ss.add(files('kvm.c'))
-  stub_ss.add(files('target-get-monitor-def.c'))
   stub_ss.add(files('win32-kbd-hook.c'))
   stub_ss.add(files('xen-hw-stub.c'))
   stub_ss.add(files('monitor-arm-gic.c'))
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 14/27] monitor/meson: Use SPICE with migration HMP commands
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (12 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 13/27] monitor: Remove target_get_monitor_def() Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 15/27] stubs: Rename monitor* -> qmp* files Philippe Mathieu-Daudé
                   ` (12 subsequent siblings)
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Peter Xu, Fabiano Rosas

When moving code around in commit 27be86351ec ("migration: Move
the QMP command from monitor/ to migration/") we forgot to update
the meson rule about SPICE pkg-config flags.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 migration/meson.build | 2 +-
 monitor/meson.build   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/migration/meson.build b/migration/meson.build
index c9f0f5f9f21..e583822dec6 100644
--- a/migration/meson.build
+++ b/migration/meson.build
@@ -23,7 +23,6 @@ system_ss.add(files(
   'fd.c',
   'file.c',
   'global_state.c',
-  'migration-hmp-cmds.c',
   'migration.c',
   'multifd.c',
   'multifd-device-state.c',
@@ -37,6 +36,7 @@ system_ss.add(files(
   'socket.c',
   'tls.c',
 ), gnutls, zlib)
+system_ss.add([spice_headers, files('migration-hmp-cmds.c'), spice])
 
 if get_option('replication').allowed()
   system_ss.add(files('colo-failover.c', 'colo.c', 'multifd-colo.c'))
diff --git a/monitor/meson.build b/monitor/meson.build
index 2647100e04c..585251804e4 100644
--- a/monitor/meson.build
+++ b/monitor/meson.build
@@ -5,8 +5,8 @@ system_ss.add(files(
   'hmp-cmds.c',
   'hmp.c',
   'qemu-config-qmp.c',
+  'qmp-cmds.c',
 ))
-system_ss.add([spice_headers, files('qmp-cmds.c')])
 
 specific_ss.add(when: 'CONFIG_SYSTEM_ONLY',
-                if_true: [files('hmp-target.c'), spice])
+                if_true: [files('hmp-target.c')])
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 15/27] stubs: Rename monitor* -> qmp* files
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (13 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 14/27] monitor/meson: Use SPICE with migration HMP commands Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 16/27] monitor: Make 'info via' a generic command Philippe Mathieu-Daudé
                   ` (11 subsequent siblings)
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Paolo Bonzini

We use 'HMP' for Human monitor and 'QMP' for 'Machine protocol'.
These files aren't about human monitor but QMP, so rename them
for clarity using the 'qmp-' prefix instead of 'monitor-'.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 MAINTAINERS                                      |  6 ++++++
 stubs/{monitor-arm-gic.c => qmp-arm-gic.c}       |  0
 ...nitor-cpu-s390x-kvm.c => qmp-cpu-s390x-kvm.c} |  0
 stubs/{monitor-cpu-s390x.c => qmp-cpu-s390x.c}   |  0
 stubs/{monitor-cpu.c => qmp-cpu.c}               |  0
 stubs/{monitor-i386-rtc.c => qmp-i386-rtc.c}     |  0
 stubs/{monitor-i386-sev.c => qmp-i386-sev.c}     |  0
 stubs/{monitor-i386-sgx.c => qmp-i386-sgx.c}     |  0
 stubs/{monitor-i386-xen.c => qmp-i386-xen.c}     |  0
 stubs/meson.build                                | 16 ++++++++--------
 10 files changed, 14 insertions(+), 8 deletions(-)
 rename stubs/{monitor-arm-gic.c => qmp-arm-gic.c} (100%)
 rename stubs/{monitor-cpu-s390x-kvm.c => qmp-cpu-s390x-kvm.c} (100%)
 rename stubs/{monitor-cpu-s390x.c => qmp-cpu-s390x.c} (100%)
 rename stubs/{monitor-cpu.c => qmp-cpu.c} (100%)
 rename stubs/{monitor-i386-rtc.c => qmp-i386-rtc.c} (100%)
 rename stubs/{monitor-i386-sev.c => qmp-i386-sev.c} (100%)
 rename stubs/{monitor-i386-sgx.c => qmp-i386-sgx.c} (100%)
 rename stubs/{monitor-i386-xen.c => qmp-i386-xen.c} (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index edbbd544d62..932d6aee507 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -121,6 +121,7 @@ F: include/hw/s390x/
 F: include/hw/watchdog/wdt_diag288.h
 F: pc-bios/s390-ccw/
 F: pc-bios/s390-ccw.img
+F: stubs/qmp-cpu-s390x.c
 F: target/s390x/
 F: docs/system/target-s390x.rst
 F: docs/system/s390x/
@@ -496,6 +497,7 @@ M: Christian Borntraeger <borntraeger@linux.ibm.com>
 R: Eric Farman <farman@linux.ibm.com>
 R: Matthew Rosato <mjrosato@linux.ibm.com>
 S: Supported
+F: stubs/qmp-cpu-s390x-kvm.c
 F: target/s390x/kvm/
 F: target/s390x/machine.c
 F: target/s390x/sigp.c
@@ -510,6 +512,8 @@ L: kvm@vger.kernel.org
 S: Supported
 F: docs/system/i386/amd-memory-encryption.rst
 F: docs/system/i386/sgx.rst
+F: stubs/qmp-i386-sev.c
+F: stubs/qmp-i386-sgx.c
 F: target/i386/kvm/
 F: target/i386/sev*
 F: scripts/kvm/vmxcap
@@ -522,6 +526,7 @@ S: Supported
 F: include/system/kvm_xen.h
 F: target/i386/kvm/xen*
 F: hw/i386/kvm/xen*
+F: stubs/qmp-i386-xen.c
 F: tests/functional/x86_64/test_kvm_xen.py
 
 Guest CPU Cores (other accelerators)
@@ -800,6 +805,7 @@ F: include/hw/timer/a9gtimer.h
 F: include/hw/timer/arm_mptimer.h
 F: include/hw/timer/armv7m_systick.h
 F: include/hw/misc/armv7m_ras.h
+F: stubs/qmp-arm-gic.c
 F: tests/qtest/test-arm-mptimer.c
 
 Bananapi M2U
diff --git a/stubs/monitor-arm-gic.c b/stubs/qmp-arm-gic.c
similarity index 100%
rename from stubs/monitor-arm-gic.c
rename to stubs/qmp-arm-gic.c
diff --git a/stubs/monitor-cpu-s390x-kvm.c b/stubs/qmp-cpu-s390x-kvm.c
similarity index 100%
rename from stubs/monitor-cpu-s390x-kvm.c
rename to stubs/qmp-cpu-s390x-kvm.c
diff --git a/stubs/monitor-cpu-s390x.c b/stubs/qmp-cpu-s390x.c
similarity index 100%
rename from stubs/monitor-cpu-s390x.c
rename to stubs/qmp-cpu-s390x.c
diff --git a/stubs/monitor-cpu.c b/stubs/qmp-cpu.c
similarity index 100%
rename from stubs/monitor-cpu.c
rename to stubs/qmp-cpu.c
diff --git a/stubs/monitor-i386-rtc.c b/stubs/qmp-i386-rtc.c
similarity index 100%
rename from stubs/monitor-i386-rtc.c
rename to stubs/qmp-i386-rtc.c
diff --git a/stubs/monitor-i386-sev.c b/stubs/qmp-i386-sev.c
similarity index 100%
rename from stubs/monitor-i386-sev.c
rename to stubs/qmp-i386-sev.c
diff --git a/stubs/monitor-i386-sgx.c b/stubs/qmp-i386-sgx.c
similarity index 100%
rename from stubs/monitor-i386-sgx.c
rename to stubs/qmp-i386-sgx.c
diff --git a/stubs/monitor-i386-xen.c b/stubs/qmp-i386-xen.c
similarity index 100%
rename from stubs/monitor-i386-xen.c
rename to stubs/qmp-i386-xen.c
diff --git a/stubs/meson.build b/stubs/meson.build
index 85f9e3a4f23..356d7800760 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -76,14 +76,14 @@ if have_system
   stub_ss.add(files('kvm.c'))
   stub_ss.add(files('win32-kbd-hook.c'))
   stub_ss.add(files('xen-hw-stub.c'))
-  stub_ss.add(files('monitor-arm-gic.c'))
-  stub_ss.add(files('monitor-i386-rtc.c'))
-  stub_ss.add(files('monitor-i386-sev.c'))
-  stub_ss.add(files('monitor-i386-sgx.c'))
-  stub_ss.add(files('monitor-i386-xen.c'))
-  stub_ss.add(files('monitor-cpu.c'))
-  stub_ss.add(files('monitor-cpu-s390x.c'))
-  stub_ss.add(files('monitor-cpu-s390x-kvm.c'))
+  stub_ss.add(files('qmp-arm-gic.c'))
+  stub_ss.add(files('qmp-i386-rtc.c'))
+  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-s390x.c'))
+  stub_ss.add(files('qmp-cpu-s390x-kvm.c'))
 endif
 
 if have_system or have_user
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 16/27] monitor: Make 'info via' a generic command
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (14 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 15/27] stubs: Rename monitor* -> qmp* files Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 17/27] monitor: Make Xen emulation commands generic ones Philippe Mathieu-Daudé
                   ` (10 subsequent siblings)
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Mark Cave-Ayland

In order to build hmp-commands-info.hx once we need to stop
using device target-specific check. Use the generic pattern
to make the command available on all targets, providing a
stub with kind error message when the device is not available.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 MAINTAINERS            |  2 +-
 hw/misc/mos6522-stub.c | 16 ++++++++++++++++
 hmp-commands-info.hx   |  2 --
 hw/misc/meson.build    |  1 +
 4 files changed, 18 insertions(+), 3 deletions(-)
 create mode 100644 hw/misc/mos6522-stub.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 932d6aee507..1810625eb1e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1558,7 +1558,7 @@ F: hw/ppc/mac_newworld.c
 F: hw/pci-host/uninorth.c
 F: hw/pci-bridge/dec.[hc]
 F: hw/misc/macio/
-F: hw/misc/mos6522.c
+F: hw/misc/mos6522*.c
 F: hw/nvram/mac_nvram.c
 F: hw/ppc/fw_cfg.c
 F: hw/input/adb*
diff --git a/hw/misc/mos6522-stub.c b/hw/misc/mos6522-stub.c
new file mode 100644
index 00000000000..85eb0ee36ee
--- /dev/null
+++ b/hw/misc/mos6522-stub.c
@@ -0,0 +1,16 @@
+/*
+ * QEMU MOS6522 VIA stubs
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "monitor/monitor.h"
+#include "monitor/hmp.h"
+
+void hmp_info_via(Monitor *mon, const QDict *qdict)
+{
+    monitor_printf(mon, "MOS6522 VIA is not available in this QEMU\n");
+}
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 74c741f80e2..463038c302a 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -885,7 +885,6 @@ SRST
     Show intel SGX information.
 ERST
 
-#if defined(CONFIG_MOS6522)
     {
         .name         = "via",
         .args_type    = "",
@@ -893,7 +892,6 @@ ERST
         .help         = "show guest mos6522 VIA devices",
         .cmd          = hmp_info_via,
     },
-#endif
 
 SRST
   ``info via``
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
index 245ab9b98cc..d7e97a4a32f 100644
--- a/hw/misc/meson.build
+++ b/hw/misc/meson.build
@@ -20,6 +20,7 @@ system_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_ras.c'))
 
 # Mac devices
 system_ss.add(when: 'CONFIG_MOS6522', if_true: files('mos6522.c'))
+stub_ss.add(files('mos6522-stub.c'))
 system_ss.add(when: 'CONFIG_DJMEMC', if_true: files('djmemc.c'))
 system_ss.add(when: 'CONFIG_IOSB', if_true: files('iosb.c'))
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 17/27] monitor: Make Xen emulation commands generic ones
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (15 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 16/27] monitor: Make 'info via' a generic command Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 20:03   ` David Woodhouse
  2026-04-10 19:53 ` [PATCH v2 18/27] system: Expose 'arch_init.h' as 'qemu/target-arch-defs.h' Philippe Mathieu-Daudé
                   ` (9 subsequent siblings)
  26 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, David Woodhouse, Paul Durrant,
	Paolo Bonzini, Michael S. Tsirkin, Marcel Apfelbaum

In order to build hmp-commands.hx once we need to stop using
device target-specific check. Use the generic pattern to make
the command available on all targets, providing a stub with
kind error message when the feature is not available.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/i386/kvm/xen-stubs.c | 12 ++++++++++++
 hmp-commands.hx         |  2 --
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/hw/i386/kvm/xen-stubs.c b/hw/i386/kvm/xen-stubs.c
index ce73119ee7a..bf6ac28bef4 100644
--- a/hw/i386/kvm/xen-stubs.c
+++ b/hw/i386/kvm/xen-stubs.c
@@ -12,6 +12,8 @@
 #include "qemu/osdep.h"
 
 #include "qapi/error.h"
+#include "monitor/monitor.h"
+#include "monitor/hmp.h"
 
 #include "xen_evtchn.h"
 #include "xen_primary_console.h"
@@ -37,3 +39,13 @@ void xen_primary_console_create(void)
 void xen_primary_console_set_be_port(uint16_t port)
 {
 }
+
+void hmp_xen_event_list(Monitor *mon, const QDict *qdict)
+{
+    monitor_printf(mon, "XEN emulation is not available in this QEMU\n");
+}
+
+void hmp_xen_event_inject(Monitor *mon, const QDict *qdict)
+{
+    monitor_printf(mon, "XEN emulation is not available in this QEMU\n");
+}
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 5cc4788f12d..06d7b17bf25 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1839,7 +1839,6 @@ SRST
 ERST
 #endif
 
-#if defined(CONFIG_XEN_EMU)
     {
         .name       = "xen-event-inject",
         .args_type  = "port:i",
@@ -1866,4 +1865,3 @@ SRST
 ``xen-event-list``
   List event channels in the guest
 ERST
-#endif
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 18/27] system: Expose 'arch_init.h' as 'qemu/target-arch-defs.h'
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (16 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 17/27] monitor: Make Xen emulation commands generic ones Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 19/27] monitor: Introduce HMPCommand::arch_bitmask field Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Michael S. Tsirkin, Marcel Apfelbaum,
	Paolo Bonzini, Daniel P. Berrangé

We already have a file unit outside of the local system'
folder which include "system/arch_init.h". We want more files
to use it, so make it official it is a generic header by moving
it under include. Rename as "qemu/base-arch-defs.h" which is
more descriptive.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 system/arch_init.h => include/qemu/base-arch-defs.h | 10 ++++++++--
 hw/pci/pci.c                                        |  2 +-
 system/arch_init.c                                  |  2 +-
 system/qdev-monitor.c                               |  2 +-
 system/vl.c                                         |  2 +-
 5 files changed, 12 insertions(+), 6 deletions(-)
 rename system/arch_init.h => include/qemu/base-arch-defs.h (92%)

diff --git a/system/arch_init.h b/include/qemu/base-arch-defs.h
similarity index 92%
rename from system/arch_init.h
rename to include/qemu/base-arch-defs.h
index 0c2b1f3a5d0..f33465738c9 100644
--- a/system/arch_init.h
+++ b/include/qemu/base-arch-defs.h
@@ -1,5 +1,11 @@
-#ifndef QEMU_ARCH_INIT_H
-#define QEMU_ARCH_INIT_H
+/*
+ * QEMU base architecture bit definitions
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef QEMU_BASE_ARCH_DEFS_H
+#define QEMU_BASE_ARCH_DEFS_H
 
 #include "qapi/qapi-types-machine.h"
 
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 2c3657d00de..a38dffd4899 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -36,7 +36,7 @@
 #include "migration/qemu-file-types.h"
 #include "migration/vmstate.h"
 #include "net/net.h"
-#include "system/arch_init.h"
+#include "qemu/base-arch-defs.h"
 #include "system/numa.h"
 #include "system/runstate.h"
 #include "system/system.h"
diff --git a/system/arch_init.c b/system/arch_init.c
index 604d5909ed0..1ad2f3d6f78 100644
--- a/system/arch_init.c
+++ b/system/arch_init.c
@@ -22,7 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-#include "system/arch_init.h"
+#include "qemu/base-arch-defs.h"
 #include "qemu/bitops.h"
 #include "qemu/target-info-qapi.h"
 
diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
index 2ed95e83602..2e9dbb9b5c2 100644
--- a/system/qdev-monitor.c
+++ b/system/qdev-monitor.c
@@ -23,7 +23,7 @@
 #include "monitor/hmp-completion.h"
 #include "monitor/monitor.h"
 #include "monitor/qdev.h"
-#include "system/arch_init.h"
+#include "qemu/base-arch-defs.h"
 #include "system/runstate.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-qdev.h"
diff --git a/system/vl.c b/system/vl.c
index 246623b3196..23f1da66369 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -112,7 +112,7 @@
 #include "trace/control.h"
 #include "qemu/plugin.h"
 #include "qemu/queue.h"
-#include "system/arch_init.h"
+#include "qemu/base-arch-defs.h"
 #include "system/confidential-guest-support.h"
 
 #include "ui/qemu-spice.h"
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 19/27] monitor: Introduce HMPCommand::arch_bitmask field
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (17 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 18/27] system: Expose 'arch_init.h' as 'qemu/target-arch-defs.h' Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-13  4:41   ` Richard Henderson
  2026-04-10 19:53 ` [PATCH v2 20/27] hw/s390x: Reduce 'monitor/monitor.h' inclusions Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  26 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé

Add the @arch_bitmask field to the HMPCommand structure,
allowing to restrict a command to a set of target
architectures (represented by the QEMU_ARCH_* enum constants).

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 monitor/monitor-internal.h | 6 ++++++
 monitor/hmp-target.c       | 1 +
 monitor/hmp.c              | 4 ++++
 3 files changed, 11 insertions(+)

diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
index 3ecd394ecf6..78281928e7a 100644
--- a/monitor/monitor-internal.h
+++ b/monitor/monitor-internal.h
@@ -74,6 +74,12 @@ typedef struct HMPCommand {
     const char *params;
     const char *help;
     const char *flags; /* p=preconfig */
+    /**
+     * @arch_bitmask: bitmask of QEMU_ARCH_* constants
+     *     Allow to restrict the command for a particular set of
+     *     target architectures.
+     */
+    uint32_t arch_bitmask;
     void (*cmd)(Monitor *mon, const QDict *qdict);
     /*
      * If implementing a command that takes no arguments and simply
diff --git a/monitor/hmp-target.c b/monitor/hmp-target.c
index d07e545ef7e..9d8dcb8835a 100644
--- a/monitor/hmp-target.c
+++ b/monitor/hmp-target.c
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/base-arch-defs.h"
 #include "monitor-internal.h"
 #include "monitor/qdev.h"
 #include "net/slirp.h"
diff --git a/monitor/hmp.c b/monitor/hmp.c
index 3b9e180c1ca..c1e99c462b8 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -36,6 +36,7 @@
 #include "qemu/cutils.h"
 #include "qemu/log.h"
 #include "qemu/option.h"
+#include "qemu/base-arch-defs.h"
 #include "qemu/target-info.h"
 #include "qemu/units.h"
 #include "exec/gdbstub.h"
@@ -219,6 +220,9 @@ static bool cmd_can_preconfig(const HMPCommand *cmd)
 
 static bool cmd_available(const HMPCommand *cmd)
 {
+    if (cmd->arch_bitmask && !qemu_arch_available(cmd->arch_bitmask)) {
+        return false;
+    }
     return phase_check(PHASE_MACHINE_READY) || cmd_can_preconfig(cmd);
 }
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 20/27] hw/s390x: Reduce 'monitor/monitor.h' inclusions
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (18 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 19/27] monitor: Introduce HMPCommand::arch_bitmask field Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-13  8:08   ` Cornelia Huck
  2026-04-10 19:53 ` [PATCH v2 21/27] monitor: Do not check TARGET_S390X to build s390x commands Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  26 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Halil Pasic, Christian Borntraeger,
	Jason Herne, Eric Farman, Matthew Rosato, Ilya Leoshkevich,
	David Hildenbrand, Cornelia Huck

We want to make the HMP commands available for all targets,
move the declarations to "monitor/hmp.h" where all other
are, and only include the monitor headers in the source files.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/s390x/storage-attributes.h | 4 ----
 include/hw/s390x/storage-keys.h       | 3 ---
 include/monitor/hmp.h                 | 5 +++++
 hw/s390x/s390-skeys.c                 | 2 ++
 hw/s390x/s390-stattrib.c              | 2 ++
 5 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/include/hw/s390x/storage-attributes.h b/include/hw/s390x/storage-attributes.h
index 66716a97c05..0305873b019 100644
--- a/include/hw/s390x/storage-attributes.h
+++ b/include/hw/s390x/storage-attributes.h
@@ -13,7 +13,6 @@
 #define S390_STORAGE_ATTRIBUTES_H
 
 #include "hw/core/qdev.h"
-#include "monitor/monitor.h"
 #include "qom/object.h"
 
 #define TYPE_S390_STATTRIB "s390-storage_attributes"
@@ -72,7 +71,4 @@ static inline Object *kvm_s390_stattrib_create(void)
 }
 #endif
 
-void hmp_info_cmma(Monitor *mon, const QDict *qdict);
-void hmp_migrationmode(Monitor *mon, const QDict *qdict);
-
 #endif /* S390_STORAGE_ATTRIBUTES_H */
diff --git a/include/hw/s390x/storage-keys.h b/include/hw/s390x/storage-keys.h
index 2d02936c31c..666c05e2996 100644
--- a/include/hw/s390x/storage-keys.h
+++ b/include/hw/s390x/storage-keys.h
@@ -13,7 +13,6 @@
 #define S390_STORAGE_KEYS_H
 
 #include "hw/core/qdev.h"
-#include "monitor/monitor.h"
 #include "qom/object.h"
 
 #define TYPE_S390_SKEYS "s390-skeys"
@@ -123,8 +122,6 @@ int s390_skeys_set(S390SKeysState *ks, uint64_t start_gfn,
 S390SKeysState *s390_get_skeys_device(void);
 
 void s390_qmp_dump_skeys(const char *filename, Error **errp);
-void hmp_dump_skeys(Monitor *mon, const QDict *qdict);
-void hmp_info_skeys(Monitor *mon, const QDict *qdict);
 
 #define TYPE_DUMP_SKEYS_INTERFACE "dump-skeys-interface"
 
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index b444095f684..a0a063db8e4 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -182,4 +182,9 @@ void hmp_gva2gpa(Monitor *mon, const QDict *qdict);
 void hmp_gpa2hva(Monitor *mon, const QDict *qdict);
 void hmp_gpa2hpa(Monitor *mon, const QDict *qdict);
 
+void hmp_dump_skeys(Monitor *mon, const QDict *qdict);
+void hmp_info_skeys(Monitor *mon, const QDict *qdict);
+void hmp_info_cmma(Monitor *mon, const QDict *qdict);
+void hmp_migrationmode(Monitor *mon, const QDict *qdict);
+
 #endif
diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c
index d974d97b5e7..7dca67d6618 100644
--- a/hw/s390x/s390-skeys.c
+++ b/hw/s390x/s390-skeys.c
@@ -24,6 +24,8 @@
 #include "system/kvm.h"
 #include "migration/qemu-file-types.h"
 #include "migration/register.h"
+#include "monitor/hmp.h"
+#include "monitor/monitor.h"
 #include "trace.h"
 
 #define S390_SKEYS_BUFFER_SIZE (128 * KiB)  /* Room for 128k storage keys */
diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c
index 2e83aa211cd..74b23b0a995 100644
--- a/hw/s390x/s390-stattrib.c
+++ b/hw/s390x/s390-stattrib.c
@@ -15,6 +15,8 @@
 #include "system/ram_addr.h"
 #include "migration/qemu-file.h"
 #include "migration/register.h"
+#include "monitor/hmp.h"
+#include "monitor/monitor.h"
 #include "hw/core/qdev-properties.h"
 #include "hw/s390x/storage-attributes.h"
 #include "qemu/error-report.h"
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 21/27] monitor: Do not check TARGET_S390X to build s390x commands
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (19 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 20/27] hw/s390x: Reduce 'monitor/monitor.h' inclusions Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-13  8:10   ` Cornelia Huck
  2026-04-10 19:53 ` [PATCH v2 22/27] monitor: Do not check TARGET_I386 to build target/i386/ commands Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  26 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Cornelia Huck, Eric Farman,
	Matthew Rosato, Paolo Bonzini

These commands are filtered at build-time for s390x binary.
By using the recently introduced HMPCommand::arch_bitmask flag
we can filter them at runtime, making it possible to compile
hmp-commands[-info].hx files once.

Since the methods are used inconditionally within hw/s390x/,
define them in the same stub file.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 MAINTAINERS               |  1 +
 include/monitor/hmp.h     |  7 +++++++
 monitor/hmp-target.c      |  5 -----
 stubs/hmp-cmds-hw-s390x.c | 15 +++++++++++++++
 hmp-commands-info.hx      |  6 ++----
 hmp-commands.hx           |  6 ++----
 stubs/meson.build         |  1 +
 7 files changed, 28 insertions(+), 13 deletions(-)
 create mode 100644 stubs/hmp-cmds-hw-s390x.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 1810625eb1e..e53158143a8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -122,6 +122,7 @@ F: include/hw/watchdog/wdt_diag288.h
 F: pc-bios/s390-ccw/
 F: pc-bios/s390-ccw.img
 F: stubs/qmp-cpu-s390x.c
+F: stubs/hmp-cmds-hw-s390x.c
 F: target/s390x/
 F: docs/system/target-s390x.rst
 F: docs/system/s390x/
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index a0a063db8e4..c8ce8579424 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -16,6 +16,13 @@
 
 #include "qemu/readline.h"
 #include "qapi/qapi-types-common.h"
+#include "monitor/monitor.h"
+
+#define HMP_STUB(cmd) \
+    void hmp_##cmd(Monitor *mon, const QDict *qdict) \
+    { \
+        g_assert_not_reached(); \
+    }
 
 struct MonitorDef {
     const char *name;
diff --git a/monitor/hmp-target.c b/monitor/hmp-target.c
index 9d8dcb8835a..4968d511101 100644
--- a/monitor/hmp-target.c
+++ b/monitor/hmp-target.c
@@ -35,11 +35,6 @@
 #include "qapi/qapi-commands-misc.h"
 #include "qapi/qapi-commands-machine.h"
 
-#if defined(TARGET_S390X)
-#include "hw/s390x/storage-keys.h"
-#include "hw/s390x/storage-attributes.h"
-#endif
-
 /* Make devices configuration available for use in hmp-commands*.hx templates */
 #include CONFIG_DEVICES
 
diff --git a/stubs/hmp-cmds-hw-s390x.c b/stubs/hmp-cmds-hw-s390x.c
new file mode 100644
index 00000000000..2b4f4cac79f
--- /dev/null
+++ b/stubs/hmp-cmds-hw-s390x.c
@@ -0,0 +1,15 @@
+/*
+ * Human Monitor hw/s390x stubs
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "monitor/hmp.h"
+
+HMP_STUB(dump_skeys)
+HMP_STUB(info_cmma)
+HMP_STUB(info_skeys)
+HMP_STUB(migrationmode)
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 463038c302a..28dec25642d 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -717,30 +717,28 @@ SRST
     Show rocker OF-DPA groups.
 ERST
 
-#if defined(TARGET_S390X)
     {
         .name       = "skeys",
         .args_type  = "addr:l",
         .params     = "address",
         .help       = "Display the value of a storage key",
         .cmd        = hmp_info_skeys,
+        .arch_bitmask = QEMU_ARCH_S390X,
     },
-#endif
 
 SRST
   ``info skeys`` *address*
     Display the value of a storage key (s390 only)
 ERST
 
-#if defined(TARGET_S390X)
     {
         .name       = "cmma",
         .args_type  = "addr:l,count:l?",
         .params     = "address [count]",
         .help       = "Display the values of the CMMA storage attributes for a range of pages",
         .cmd        = hmp_info_cmma,
+        .arch_bitmask = QEMU_ARCH_S390X,
     },
-#endif
 
 SRST
   ``info cmma`` *address*
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 06d7b17bf25..ff65b39b454 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1125,30 +1125,28 @@ SRST
 
 ERST
 
-#if defined(TARGET_S390X)
     {
         .name       = "dump-skeys",
         .args_type  = "filename:F",
         .params     = "",
         .help       = "Save guest storage keys into file 'filename'.\n",
         .cmd        = hmp_dump_skeys,
+        .arch_bitmask = QEMU_ARCH_S390X,
     },
-#endif
 
 SRST
 ``dump-skeys`` *filename*
   Save guest storage keys to a file.
 ERST
 
-#if defined(TARGET_S390X)
     {
         .name       = "migration_mode",
         .args_type  = "mode:i",
         .params     = "mode",
         .help       = "Enables or disables migration mode\n",
         .cmd        = hmp_migrationmode,
+        .arch_bitmask = QEMU_ARCH_S390X,
     },
-#endif
 
 SRST
 ``migration_mode`` *mode*
diff --git a/stubs/meson.build b/stubs/meson.build
index 356d7800760..d4a6bc0dde4 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -84,6 +84,7 @@ if have_system
   stub_ss.add(files('qmp-cpu.c'))
   stub_ss.add(files('qmp-cpu-s390x.c'))
   stub_ss.add(files('qmp-cpu-s390x-kvm.c'))
+  stub_ss.add(files('hmp-cmds-hw-s390x.c'))
 endif
 
 if have_system or have_user
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 22/27] monitor: Do not check TARGET_I386 to build target/i386/ commands
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (20 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 21/27] monitor: Do not check TARGET_S390X to build s390x commands Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 23/27] monitor: Do not check TARGET_I386 to build 'info sgx' command Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Paolo Bonzini, Zhao Liu

These commands are filtered at build-time for i386/x86_64 binaries.
By using the recently introduced HMPCommand::arch_bitmask flag
we can filter them at runtime, making it possible to compile
hmp-commands[-info].hx files once.

Since these methods are used inconditionally within target/i386/,
define them in the same stub file.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 MAINTAINERS                  |  1 +
 stubs/hmp-cmds-target-i386.c | 13 +++++++++++++
 hmp-commands-info.hx         |  4 +---
 hmp-commands.hx              |  5 +----
 stubs/meson.build            |  1 +
 5 files changed, 17 insertions(+), 7 deletions(-)
 create mode 100644 stubs/hmp-cmds-target-i386.c

diff --git a/MAINTAINERS b/MAINTAINERS
index e53158143a8..458951bc051 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -148,6 +148,7 @@ F: configs/targets/i386-softmmu.mak
 F: configs/targets/x86_64-softmmu.mak
 F: docs/system/i386/
 F: docs/system/target-i386*
+F: stubs/hmp-cmds-target-i386.c
 F: target/i386/*.[ch]
 F: target/i386/Kconfig
 F: target/i386/meson.build
diff --git a/stubs/hmp-cmds-target-i386.c b/stubs/hmp-cmds-target-i386.c
new file mode 100644
index 00000000000..43a167056d5
--- /dev/null
+++ b/stubs/hmp-cmds-target-i386.c
@@ -0,0 +1,13 @@
+/*
+ * Human Monitor x86 stubs
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "monitor/hmp.h"
+
+HMP_STUB(info_local_apic)
+HMP_STUB(mce)
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 28dec25642d..b575e4ac993 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -113,16 +113,14 @@ SRST
     Show the cpu registers.
 ERST
 
-#if defined(TARGET_I386)
     {
         .name       = "lapic",
         .args_type  = "apic-id:i?",
         .params     = "[apic-id]",
         .help       = "show local apic state (apic-id: local apic to read, default is which of current CPU)",
-
         .cmd        = hmp_info_local_apic,
+        .arch_bitmask = QEMU_ARCH_I386,
     },
-#endif
 
 SRST
   ``info lapic``
diff --git a/hmp-commands.hx b/hmp-commands.hx
index ff65b39b454..cfd53bdc744 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1488,18 +1488,15 @@ SRST
   Stop the QEMU embedded NBD server.
 ERST
 
-
-#if defined(TARGET_I386)
-
     {
         .name       = "mce",
         .args_type  = "broadcast:-b,cpu_index:i,bank:i,status:l,mcg_status:l,addr:l,misc:l",
         .params     = "[-b] cpu bank status mcgstatus addr misc",
         .help       = "inject a MCE on the given CPU [and broadcast to other CPUs with -b option]",
         .cmd        = hmp_mce,
+        .arch_bitmask = QEMU_ARCH_I386,
     },
 
-#endif
 SRST
 ``mce`` *cpu* *bank* *status* *mcgstatus* *addr* *misc*
   Inject an MCE on the given CPU (x86 only).
diff --git a/stubs/meson.build b/stubs/meson.build
index d4a6bc0dde4..dc289e3a482 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -85,6 +85,7 @@ if have_system
   stub_ss.add(files('qmp-cpu-s390x.c'))
   stub_ss.add(files('qmp-cpu-s390x-kvm.c'))
   stub_ss.add(files('hmp-cmds-hw-s390x.c'))
+  stub_ss.add(files('hmp-cmds-target-i386.c'))
 endif
 
 if have_system or have_user
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 23/27] monitor: Do not check TARGET_I386 to build 'info sgx' command
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (21 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 22/27] monitor: Do not check TARGET_I386 to build target/i386/ commands Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 24/27] monitor: Do not check TARGET_I386 to build 'info sev' command Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Michael S. Tsirkin, Marcel Apfelbaum,
	Paolo Bonzini, Marcelo Tosatti

This command is filtered at build-time for i386/x86_64 binaries.
By using the recently introduced HMPCommand::arch_bitmask flag
we can filter it at runtime, making it possible to compile
hmp-commands-info.hx once.

Since the method depends on the CONFIG_SGX definition, define it
in its own stub file.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 MAINTAINERS            |  1 +
 hw/i386/sgx-hmp-stub.c | 16 ++++++++++++++++
 hw/i386/sgx-stub.c     |  5 -----
 hmp-commands-info.hx   |  3 +--
 hw/i386/meson.build    |  1 +
 5 files changed, 19 insertions(+), 7 deletions(-)
 create mode 100644 hw/i386/sgx-hmp-stub.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 458951bc051..31e973fdeb0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -514,6 +514,7 @@ L: kvm@vger.kernel.org
 S: Supported
 F: docs/system/i386/amd-memory-encryption.rst
 F: docs/system/i386/sgx.rst
+F: hw/i386/sgx*
 F: stubs/qmp-i386-sev.c
 F: stubs/qmp-i386-sgx.c
 F: target/i386/kvm/
diff --git a/hw/i386/sgx-hmp-stub.c b/hw/i386/sgx-hmp-stub.c
new file mode 100644
index 00000000000..cf1d9a6344b
--- /dev/null
+++ b/hw/i386/sgx-hmp-stub.c
@@ -0,0 +1,16 @@
+/*
+ * Human Monitor 'info sgx' stub (CONFIG_SGX)
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "monitor/hmp.h"
+#include "monitor/monitor.h"
+
+void hmp_info_sgx(Monitor *mon, const QDict *qdict)
+{
+    monitor_printf(mon, "SGX is not available in this QEMU\n");
+}
diff --git a/hw/i386/sgx-stub.c b/hw/i386/sgx-stub.c
index 6e82773a86d..59d58926311 100644
--- a/hw/i386/sgx-stub.c
+++ b/hw/i386/sgx-stub.c
@@ -22,11 +22,6 @@ SgxInfo *qmp_query_sgx_capabilities(Error **errp)
     return NULL;
 }
 
-void hmp_info_sgx(Monitor *mon, const QDict *qdict)
-{
-    monitor_printf(mon, "SGX is not available in this QEMU\n");
-}
-
 void pc_machine_init_sgx_epc(PCMachineState *pcms)
 {
     memset(&pcms->sgx_epc, 0, sizeof(SGXEPCState));
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index b575e4ac993..da9fdc0ab7b 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -866,15 +866,14 @@ SRST
     Display the vcpu dirty page limit information.
 ERST
 
-#if defined(TARGET_I386)
     {
         .name       = "sgx",
         .args_type  = "",
         .params     = "",
         .help       = "show intel SGX information",
         .cmd        = hmp_info_sgx,
+        .arch_bitmask = QEMU_ARCH_I386,
     },
-#endif
 
 SRST
   ``info sgx``
diff --git a/hw/i386/meson.build b/hw/i386/meson.build
index 63ae57baa51..b611fbb5a7f 100644
--- a/hw/i386/meson.build
+++ b/hw/i386/meson.build
@@ -24,6 +24,7 @@ i386_ss.add(when: 'CONFIG_VTD', if_true: files('intel_iommu.c'))
 i386_ss.add(when: 'CONFIG_VTD_ACCEL', if_true: files('intel_iommu_accel.c'))
 i386_ss.add(when: 'CONFIG_SGX', if_true: files('sgx-epc.c','sgx.c'),
                                 if_false: files('sgx-stub.c'))
+stub_ss.add(files('sgx-hmp-stub.c'))
 
 i386_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-common.c'))
 i386_ss.add(when: 'CONFIG_PC', if_true: files(
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 24/27] monitor: Do not check TARGET_I386 to build 'info sev' command
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (22 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 23/27] monitor: Do not check TARGET_I386 to build 'info sgx' command Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 25/27] monitor: Do not check TARGET_I386/RISCV to build 'info mem' command Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Paolo Bonzini, Marcelo Tosatti,
	Zhao Liu

This command is filtered at build-time for i386/x86_64 binaries.
By using the recently introduced HMPCommand::arch_bitmask flag
we can filter it at runtime, making it possible to compile
hmp-commands-info.hx once.

Since the method depends on the CONFIG_SEV definition, define it
in its own stub file.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 MAINTAINERS                   |  1 +
 stubs/hmp-cmd-info_sev.c      | 16 ++++++++++++++++
 target/i386/sev-system-stub.c |  5 -----
 hmp-commands-info.hx          |  3 +--
 stubs/meson.build             |  1 +
 5 files changed, 19 insertions(+), 7 deletions(-)
 create mode 100644 stubs/hmp-cmd-info_sev.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 31e973fdeb0..5dcd24a8a89 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -515,6 +515,7 @@ S: Supported
 F: docs/system/i386/amd-memory-encryption.rst
 F: docs/system/i386/sgx.rst
 F: hw/i386/sgx*
+F: stubs/hmp-cmd-info_sev.c
 F: stubs/qmp-i386-sev.c
 F: stubs/qmp-i386-sgx.c
 F: target/i386/kvm/
diff --git a/stubs/hmp-cmd-info_sev.c b/stubs/hmp-cmd-info_sev.c
new file mode 100644
index 00000000000..f3624423a33
--- /dev/null
+++ b/stubs/hmp-cmd-info_sev.c
@@ -0,0 +1,16 @@
+/*
+ * Human Monitor 'info sev' stub (CONFIG_SEV)
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "monitor/hmp.h"
+#include "monitor/monitor.h"
+
+void hmp_info_sev(Monitor *mon, const QDict *qdict)
+{
+    monitor_printf(mon, "SEV is not available in this QEMU\n");
+}
diff --git a/target/i386/sev-system-stub.c b/target/i386/sev-system-stub.c
index f799a338d60..d97536cca1c 100644
--- a/target/i386/sev-system-stub.c
+++ b/target/i386/sev-system-stub.c
@@ -31,11 +31,6 @@ int sev_es_save_reset_vector(void *flash_ptr, uint64_t flash_size)
     g_assert_not_reached();
 }
 
-void hmp_info_sev(Monitor *mon, const QDict *qdict)
-{
-    monitor_printf(mon, "SEV is not available in this QEMU\n");
-}
-
 void pc_system_parse_sev_metadata(uint8_t *flash_ptr, size_t flash_size)
 {
 }
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index da9fdc0ab7b..336ab870a2c 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -812,15 +812,14 @@ SRST
     enabled) memory in bytes.
 ERST
 
-#if defined(TARGET_I386)
     {
         .name       = "sev",
         .args_type  = "",
         .params     = "",
         .help       = "show SEV information",
         .cmd        = hmp_info_sev,
+        .arch_bitmask = QEMU_ARCH_I386,
     },
-#endif
 
 SRST
   ``info sev``
diff --git a/stubs/meson.build b/stubs/meson.build
index dc289e3a482..09e73ef8b73 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -84,6 +84,7 @@ if have_system
   stub_ss.add(files('qmp-cpu.c'))
   stub_ss.add(files('qmp-cpu-s390x.c'))
   stub_ss.add(files('qmp-cpu-s390x-kvm.c'))
+  stub_ss.add(files('hmp-cmd-info_sev.c'))
   stub_ss.add(files('hmp-cmds-hw-s390x.c'))
   stub_ss.add(files('hmp-cmds-target-i386.c'))
 endif
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 25/27] monitor: Do not check TARGET_I386/RISCV to build 'info mem' command
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (23 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 24/27] monitor: Do not check TARGET_I386 to build 'info sev' command Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 26/27] monitor: Do not check multiple TARGET_* to build 'info tlb' command Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 27/27] monitor: Merge hmp-target.c code within hmp-cmds.c Philippe Mathieu-Daudé
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Paolo Bonzini

This command is filtered at build-time for i386/x86_64 and
riscv32/riscv64 binaries. By using the recently introduced
HMPCommand::arch_bitmask flag we can filter it at runtime,
making it possible to compile hmp-commands-info.hx once.

Since the method depends on a pair of distinct targets,
define it in its own stub file.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 stubs/hmp-cmd-info_mem.c | 12 ++++++++++++
 hmp-commands-info.hx     |  3 +--
 stubs/meson.build        |  1 +
 3 files changed, 14 insertions(+), 2 deletions(-)
 create mode 100644 stubs/hmp-cmd-info_mem.c

diff --git a/stubs/hmp-cmd-info_mem.c b/stubs/hmp-cmd-info_mem.c
new file mode 100644
index 00000000000..8a53e367a9f
--- /dev/null
+++ b/stubs/hmp-cmd-info_mem.c
@@ -0,0 +1,12 @@
+/*
+ * Human Monitor 'info mem' stub
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "monitor/hmp.h"
+
+HMP_STUB(info_mem)
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 336ab870a2c..2d0a8f7d48f 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -209,15 +209,14 @@ SRST
     Show virtual to physical memory mappings.
 ERST
 
-#if defined(TARGET_I386) || defined(TARGET_RISCV)
     {
         .name       = "mem",
         .args_type  = "",
         .params     = "",
         .help       = "show the active virtual memory mappings",
         .cmd        = hmp_info_mem,
+        .arch_bitmask = QEMU_ARCH_I386 | QEMU_ARCH_RISCV,
     },
-#endif
 
 SRST
   ``info mem``
diff --git a/stubs/meson.build b/stubs/meson.build
index 09e73ef8b73..ed7ca54ae06 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -84,6 +84,7 @@ if have_system
   stub_ss.add(files('qmp-cpu.c'))
   stub_ss.add(files('qmp-cpu-s390x.c'))
   stub_ss.add(files('qmp-cpu-s390x-kvm.c'))
+  stub_ss.add(files('hmp-cmd-info_mem.c'))
   stub_ss.add(files('hmp-cmd-info_sev.c'))
   stub_ss.add(files('hmp-cmds-hw-s390x.c'))
   stub_ss.add(files('hmp-cmds-target-i386.c'))
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 26/27] monitor: Do not check multiple TARGET_* to build 'info tlb' command
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (24 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 25/27] monitor: Do not check TARGET_I386/RISCV to build 'info mem' command Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-10 19:53 ` [PATCH v2 27/27] monitor: Merge hmp-target.c code within hmp-cmds.c Philippe Mathieu-Daudé
  26 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Paolo Bonzini

This command is filtered at build-time for a selection of binaries.
By using the recently introduced HMPCommand::arch_bitmask flag we
can filter them at runtime, making it possible to compile
hmp-commands-info.hx once.

Since the method depends on a pair of distinct targets,
define it in its own stub file.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 stubs/hmp-cmd-info_tlb.c | 12 ++++++++++++
 hmp-commands-info.hx     |  5 ++---
 stubs/meson.build        |  1 +
 3 files changed, 15 insertions(+), 3 deletions(-)
 create mode 100644 stubs/hmp-cmd-info_tlb.c

diff --git a/stubs/hmp-cmd-info_tlb.c b/stubs/hmp-cmd-info_tlb.c
new file mode 100644
index 00000000000..a144e68c1c7
--- /dev/null
+++ b/stubs/hmp-cmd-info_tlb.c
@@ -0,0 +1,12 @@
+/*
+ * Human Monitor 'info tlb' stub
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "monitor/hmp.h"
+
+HMP_STUB(info_tlb)
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 2d0a8f7d48f..0898221a486 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -193,16 +193,15 @@ SRST
     Show PCI information.
 ERST
 
-#if defined(TARGET_I386) || defined(TARGET_SH4) || defined(TARGET_SPARC) || \
-    defined(TARGET_PPC) || defined(TARGET_XTENSA) || defined(TARGET_M68K)
     {
         .name       = "tlb",
         .args_type  = "",
         .params     = "",
         .help       = "show virtual to physical memory mappings",
         .cmd        = hmp_info_tlb,
+        .arch_bitmask = QEMU_ARCH_I386 | QEMU_ARCH_SH4 | QEMU_ARCH_SPARC \
+                        | QEMU_ARCH_PPC | QEMU_ARCH_XTENSA | QEMU_ARCH_M68K,
     },
-#endif
 
 SRST
   ``info tlb``
diff --git a/stubs/meson.build b/stubs/meson.build
index ed7ca54ae06..3c6d0032e93 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -86,6 +86,7 @@ if have_system
   stub_ss.add(files('qmp-cpu-s390x-kvm.c'))
   stub_ss.add(files('hmp-cmd-info_mem.c'))
   stub_ss.add(files('hmp-cmd-info_sev.c'))
+  stub_ss.add(files('hmp-cmd-info_tlb.c'))
   stub_ss.add(files('hmp-cmds-hw-s390x.c'))
   stub_ss.add(files('hmp-cmds-target-i386.c'))
 endif
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 27/27] monitor: Merge hmp-target.c code within hmp-cmds.c
  2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
                   ` (25 preceding siblings ...)
  2026-04-10 19:53 ` [PATCH v2 26/27] monitor: Do not check multiple TARGET_* to build 'info tlb' command Philippe Mathieu-Daudé
@ 2026-04-10 19:53 ` Philippe Mathieu-Daudé
  2026-04-13  8:13   ` Richard Henderson
  26 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-10 19:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé

hmp-target.c doesn't contain any target-specific code anymore.
Merge it within hmp-cmds.c (which is already built once).

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 MAINTAINERS          |  1 -
 monitor/hmp-cmds.c   | 40 ++++++++++++++++++++++++
 monitor/hmp-target.c | 73 --------------------------------------------
 monitor/meson.build  |  3 --
 4 files changed, 40 insertions(+), 77 deletions(-)
 delete mode 100644 monitor/hmp-target.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 5dcd24a8a89..d184e25ddd4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3414,7 +3414,6 @@ Human Monitor (HMP)
 M: Dr. David Alan Gilbert <dave@treblig.org>
 S: Maintained
 F: monitor/monitor-internal.h
-F: monitor/hmp-target.c
 F: monitor/monitor.c
 F: monitor/hmp*
 F: hmp.h
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index e81632f5551..409a1a9c701 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -14,6 +14,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/base-arch-defs.h"
 #include "system/address-spaces.h"
 #include "system/ioport.h"
 #include "exec/gdbstub.h"
@@ -22,19 +23,58 @@
 #include "monitor/hmp.h"
 #include "qemu/help_option.h"
 #include "monitor/hmp.h"
+#include "monitor/hmp-completion.h"
 #include "monitor/monitor-internal.h"
+#include "monitor/qdev.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-control.h"
 #include "qapi/qapi-commands-machine.h"
 #include "qapi/qapi-commands-misc.h"
+#include "block/block-hmp-cmds.h"
 #include "qobject/qdict.h"
 #include "qemu/cutils.h"
 #include "qemu/log.h"
+#include "net/slirp.h"
+#include "system/device_tree.h"
 #include "system/hw_accel.h"
 #include "system/memory.h"
 #include "system/system.h"
 #include "disas/disas.h"
 
+/* Please update hmp-commands.hx when adding or changing commands */
+static HMPCommand hmp_info_cmds[] = {
+#include "hmp-commands-info.h"
+    { NULL, NULL, },
+};
+
+/* hmp_cmds and hmp_info_cmds would be sorted at runtime */
+static HMPCommand hmp_cmds[] = {
+#include "hmp-commands.h"
+    { NULL, NULL, },
+};
+
+HMPCommand *hmp_cmds_for_target(bool info_command)
+{
+    return info_command ? hmp_info_cmds : hmp_cmds;
+}
+
+static int
+compare_mon_cmd(const void *a, const void *b)
+{
+    return strcmp(((const HMPCommand *)a)->name,
+            ((const HMPCommand *)b)->name);
+}
+
+static void __attribute__((__constructor__)) sortcmdlist(void)
+{
+    qsort(hmp_cmds, ARRAY_SIZE(hmp_cmds) - 1,
+          sizeof(*hmp_cmds),
+          compare_mon_cmd);
+    qsort(hmp_info_cmds, ARRAY_SIZE(hmp_info_cmds) - 1,
+          sizeof(*hmp_info_cmds),
+          compare_mon_cmd);
+}
+
 bool hmp_handle_error(Monitor *mon, Error *err)
 {
     if (err) {
diff --git a/monitor/hmp-target.c b/monitor/hmp-target.c
deleted file mode 100644
index 4968d511101..00000000000
--- a/monitor/hmp-target.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * QEMU monitor, target-dependent part
- *
- * Copyright (c) 2003-2004 Fabrice Bellard
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include "qemu/osdep.h"
-#include "qemu/base-arch-defs.h"
-#include "monitor-internal.h"
-#include "monitor/qdev.h"
-#include "net/slirp.h"
-#include "system/device_tree.h"
-#include "monitor/hmp.h"
-#include "monitor/hmp-completion.h"
-#include "block/block-hmp-cmds.h"
-#include "qapi/qapi-commands-control.h"
-#include "qapi/qapi-commands-misc.h"
-#include "qapi/qapi-commands-machine.h"
-
-/* Make devices configuration available for use in hmp-commands*.hx templates */
-#include CONFIG_DEVICES
-
-/* Please update hmp-commands.hx when adding or changing commands */
-static HMPCommand hmp_info_cmds[] = {
-#include "hmp-commands-info.h"
-    { NULL, NULL, },
-};
-
-/* hmp_cmds and hmp_info_cmds would be sorted at runtime */
-static HMPCommand hmp_cmds[] = {
-#include "hmp-commands.h"
-    { NULL, NULL, },
-};
-
-HMPCommand *hmp_cmds_for_target(bool info_command)
-{
-    return info_command ? hmp_info_cmds : hmp_cmds;
-}
-
-static int
-compare_mon_cmd(const void *a, const void *b)
-{
-    return strcmp(((const HMPCommand *)a)->name,
-            ((const HMPCommand *)b)->name);
-}
-
-static void __attribute__((__constructor__)) sortcmdlist(void)
-{
-    qsort(hmp_cmds, ARRAY_SIZE(hmp_cmds) - 1,
-          sizeof(*hmp_cmds),
-          compare_mon_cmd);
-    qsort(hmp_info_cmds, ARRAY_SIZE(hmp_info_cmds) - 1,
-          sizeof(*hmp_info_cmds),
-          compare_mon_cmd);
-}
diff --git a/monitor/meson.build b/monitor/meson.build
index 585251804e4..4c58dd148c0 100644
--- a/monitor/meson.build
+++ b/monitor/meson.build
@@ -7,6 +7,3 @@ system_ss.add(files(
   'qemu-config-qmp.c',
   'qmp-cmds.c',
 ))
-
-specific_ss.add(when: 'CONFIG_SYSTEM_ONLY',
-                if_true: [files('hmp-target.c')])
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 17/27] monitor: Make Xen emulation commands generic ones
  2026-04-10 19:53 ` [PATCH v2 17/27] monitor: Make Xen emulation commands generic ones Philippe Mathieu-Daudé
@ 2026-04-10 20:03   ` David Woodhouse
  0 siblings, 0 replies; 39+ messages in thread
From: David Woodhouse @ 2026-04-10 20:03 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Paul Durrant, Paolo Bonzini, Michael S. Tsirkin, Marcel Apfelbaum

[-- Attachment #1: Type: text/plain, Size: 435 bytes --]

On Fri, 2026-04-10 at 21:53 +0200, Philippe Mathieu-Daudé wrote:
> In order to build hmp-commands.hx once we need to stop using
> device target-specific check. Use the generic pattern to make
> the command available on all targets, providing a stub with
> kind error message when the feature is not available.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Acked-by: David Woodhouse <dwmw@amazon.co.uk>



[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5069 bytes --]

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 01/27] monitor: Have MonitorDef::get_value() always return int64_t type
  2026-04-10 19:52 ` [PATCH v2 01/27] monitor: Have MonitorDef::get_value() always return int64_t type Philippe Mathieu-Daudé
@ 2026-04-13  2:42   ` Richard Henderson
  0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2026-04-13  2:42 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Dr. David Alan Gilbert, Pierrick Bouvier, qemu-riscv,
	Markus Armbruster, qemu-s390x, kvm, qemu-ppc, Paolo Bonzini,
	Zhao Liu

On 4/11/26 05:52, Philippe Mathieu-Daudé wrote:
> Simplify MonitorDef::get_value() handler by having it always
> return a int64_t type. Truncate to 32-bit in the single caller.
> 
> Note, this handler is only implemented once for the x86 targets.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/monitor/hmp-target.h | 6 +-----
>   monitor/hmp-target.c         | 4 +++-
>   target/i386/monitor.c        | 4 ++--
>   3 files changed, 6 insertions(+), 8 deletions(-)

Given there's only one use, we could just define that the hook itself extends.

> +static int64_t monitor_get_pc(Monitor *mon, const struct MonitorDef *md,
> +                              int offset)
>   {
>       CPUArchState *env = mon_get_cpu_env(mon);
>       return env->eip + env->segs[R_CS].base;

     ret = env->eip + env->segs[R_CS].base;
     if (!(env->hflags & HF_CS64_MASK)) {
         ret = (int32_t)ret;
     }

The test will always be true for i386, but will also apply when the cpu is in 32-bit or 
16-bit mode.


r~

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 02/27] monitor: Remove target_long use in get_monitor_def()
  2026-04-10 19:52 ` [PATCH v2 02/27] monitor: Remove target_long use in get_monitor_def() Philippe Mathieu-Daudé
@ 2026-04-13  2:54   ` Richard Henderson
  0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2026-04-13  2:54 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Dr. David Alan Gilbert, Pierrick Bouvier, qemu-riscv,
	Markus Armbruster, qemu-s390x, kvm, qemu-ppc

On 4/11/26 05:52, Philippe Mathieu-Daudé wrote:
> Truncate manually, removing the need of target-specific
> code in get_monitor_def().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   monitor/hmp-target.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/monitor/hmp-target.c b/monitor/hmp-target.c
> index 812714ada01..b9b79e8e927 100644
> --- a/monitor/hmp-target.c
> +++ b/monitor/hmp-target.c
> @@ -93,7 +93,7 @@ int get_monitor_def(Monitor *mon, int64_t *pval, const char *name)
>   
>       ret = target_get_monitor_def(cs, name, &tmp);
>       if (!ret) {
> -        *pval = (target_long) tmp;
> +        *pval = target_long_bits() == 32 ? (int32_t)tmp : tmp;
>       }

Likewise force the target to deal with int64_t.
There is only one user: riscv.


r~

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 03/27] monitor: Reduce target-specific methods further
  2026-04-10 19:52 ` [PATCH v2 03/27] monitor: Reduce target-specific methods further Philippe Mathieu-Daudé
@ 2026-04-13  2:54   ` Richard Henderson
  0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2026-04-13  2:54 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Dr. David Alan Gilbert, Pierrick Bouvier, qemu-riscv,
	Markus Armbruster, qemu-s390x, kvm, qemu-ppc

On 4/11/26 05:52, Philippe Mathieu-Daudé wrote:
> get_monitor_def() doesn't use any target-specific declaration
> anymore, move it to hmp.c to compile it once.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> Reviewed-by: Dr. David Alan Gilbert<dave@treblig.org>
> ---
>   monitor/monitor-internal.h |  1 -
>   monitor/hmp-target.c       | 39 -------------------------------------
>   monitor/hmp.c              | 40 ++++++++++++++++++++++++++++++++++++++
>   3 files changed, 40 insertions(+), 40 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 05/27] monitor: Forward-declare the MonitorDef type
  2026-04-10 19:52 ` [PATCH v2 05/27] monitor: Forward-declare the MonitorDef type Philippe Mathieu-Daudé
@ 2026-04-13  3:10   ` Richard Henderson
  0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2026-04-13  3:10 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Dr. David Alan Gilbert, Pierrick Bouvier, qemu-riscv,
	Markus Armbruster, qemu-s390x, kvm, qemu-ppc

On 4/11/26 05:52, Philippe Mathieu-Daudé wrote:
> Rather than having core header forced to include "monitor/hmp.h"
> to get the MonitorDef type declaration, forward-declare it in
> "qemu/typedefs.h".
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   include/monitor/hmp.h   | 6 +++---
>   include/qemu/typedefs.h | 1 +
>   2 files changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 08/27] target/m68k: Replace target_monitor_defs -> SysemuCPUOps::monitor_defs
  2026-04-10 19:53 ` [PATCH v2 08/27] target/m68k: " Philippe Mathieu-Daudé
@ 2026-04-13  3:59   ` Richard Henderson
  0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2026-04-13  3:59 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Dr. David Alan Gilbert, Pierrick Bouvier, qemu-riscv,
	Markus Armbruster, qemu-s390x, kvm, qemu-ppc, Laurent Vivier

On 4/11/26 05:53, Philippe Mathieu-Daudé wrote:
> Restrict m68k_monitor_defs[] to cpu.c, register it as
> SysemuCPUOps::monitor_defs hook, allowing to remove
> the target_monitor_defs() method.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   target/m68k/cpu.c     | 18 ++++++++++++++++++
>   target/m68k/monitor.c | 21 ---------------------
>   2 files changed, 18 insertions(+), 21 deletions(-)


Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 11/27] cpus: Introduce SysemuCPUOps::monitor_get_register() hook
  2026-04-10 19:53 ` [PATCH v2 11/27] cpus: Introduce SysemuCPUOps::monitor_get_register() hook Philippe Mathieu-Daudé
@ 2026-04-13  4:09   ` Richard Henderson
  0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2026-04-13  4:09 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Dr. David Alan Gilbert, Pierrick Bouvier, qemu-riscv,
	Markus Armbruster, qemu-s390x, kvm, qemu-ppc

On 4/11/26 05:53, Philippe Mathieu-Daudé wrote:
> Allow targets to register their legacy target_get_monitor_def()
> in SysemuCPUOps; check it first in get_monitor_def() otherwise
> fall back to previous per-target helper.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/hw/core/sysemu-cpu-ops.h | 8 ++++++++
>   monitor/hmp.c                    | 6 +++++-
>   2 files changed, 13 insertions(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 19/27] monitor: Introduce HMPCommand::arch_bitmask field
  2026-04-10 19:53 ` [PATCH v2 19/27] monitor: Introduce HMPCommand::arch_bitmask field Philippe Mathieu-Daudé
@ 2026-04-13  4:41   ` Richard Henderson
  0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2026-04-13  4:41 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Dr. David Alan Gilbert, Pierrick Bouvier, qemu-riscv,
	Markus Armbruster, qemu-s390x, kvm, qemu-ppc

On 4/11/26 05:53, Philippe Mathieu-Daudé wrote:
> Add the @arch_bitmask field to the HMPCommand structure,
> allowing to restrict a command to a set of target
> architectures (represented by the QEMU_ARCH_* enum constants).
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   monitor/monitor-internal.h | 6 ++++++
>   monitor/hmp-target.c       | 1 +
>   monitor/hmp.c              | 4 ++++
>   3 files changed, 11 insertions(+)
> 
> diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
> index 3ecd394ecf6..78281928e7a 100644
> --- a/monitor/monitor-internal.h
> +++ b/monitor/monitor-internal.h
> @@ -74,6 +74,12 @@ typedef struct HMPCommand {
>       const char *params;
>       const char *help;
>       const char *flags; /* p=preconfig */
> +    /**
> +     * @arch_bitmask: bitmask of QEMU_ARCH_* constants
> +     *     Allow to restrict the command for a particular set of
> +     *     target architectures.
> +     */
> +    uint32_t arch_bitmask;
>       void (*cmd)(Monitor *mon, const QDict *qdict);
>       /*
>        * If implementing a command that takes no arguments and simply

This and coroutine could be placed better to avoid two holes.

Otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 20/27] hw/s390x: Reduce 'monitor/monitor.h' inclusions
  2026-04-10 19:53 ` [PATCH v2 20/27] hw/s390x: Reduce 'monitor/monitor.h' inclusions Philippe Mathieu-Daudé
@ 2026-04-13  8:08   ` Cornelia Huck
  0 siblings, 0 replies; 39+ messages in thread
From: Cornelia Huck @ 2026-04-13  8:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Halil Pasic, Christian Borntraeger,
	Jason Herne, Eric Farman, Matthew Rosato, Ilya Leoshkevich,
	David Hildenbrand

On Fri, Apr 10 2026, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:

> We want to make the HMP commands available for all targets,
> move the declarations to "monitor/hmp.h" where all other
> are, and only include the monitor headers in the source files.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  include/hw/s390x/storage-attributes.h | 4 ----
>  include/hw/s390x/storage-keys.h       | 3 ---
>  include/monitor/hmp.h                 | 5 +++++
>  hw/s390x/s390-skeys.c                 | 2 ++
>  hw/s390x/s390-stattrib.c              | 2 ++
>  5 files changed, 9 insertions(+), 7 deletions(-)

Acked-by: Cornelia Huck <cohuck@redhat.com>


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 21/27] monitor: Do not check TARGET_S390X to build s390x commands
  2026-04-10 19:53 ` [PATCH v2 21/27] monitor: Do not check TARGET_S390X to build s390x commands Philippe Mathieu-Daudé
@ 2026-04-13  8:10   ` Cornelia Huck
  0 siblings, 0 replies; 39+ messages in thread
From: Cornelia Huck @ 2026-04-13  8:10 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Richard Henderson, Dr. David Alan Gilbert, Pierrick Bouvier,
	qemu-riscv, Markus Armbruster, qemu-s390x, kvm, qemu-ppc,
	Philippe Mathieu-Daudé, Eric Farman, Matthew Rosato,
	Paolo Bonzini

On Fri, Apr 10 2026, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:

> These commands are filtered at build-time for s390x binary.
> By using the recently introduced HMPCommand::arch_bitmask flag
> we can filter them at runtime, making it possible to compile
> hmp-commands[-info].hx files once.
>
> Since the methods are used inconditionally within hw/s390x/,
> define them in the same stub file.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  MAINTAINERS               |  1 +
>  include/monitor/hmp.h     |  7 +++++++
>  monitor/hmp-target.c      |  5 -----
>  stubs/hmp-cmds-hw-s390x.c | 15 +++++++++++++++
>  hmp-commands-info.hx      |  6 ++----
>  hmp-commands.hx           |  6 ++----
>  stubs/meson.build         |  1 +
>  7 files changed, 28 insertions(+), 13 deletions(-)
>  create mode 100644 stubs/hmp-cmds-hw-s390x.c

Acked-by: Cornelia Huck <cohuck@redhat.com>


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 27/27] monitor: Merge hmp-target.c code within hmp-cmds.c
  2026-04-10 19:53 ` [PATCH v2 27/27] monitor: Merge hmp-target.c code within hmp-cmds.c Philippe Mathieu-Daudé
@ 2026-04-13  8:13   ` Richard Henderson
  0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2026-04-13  8:13 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Dr. David Alan Gilbert, Pierrick Bouvier, qemu-riscv,
	Markus Armbruster, qemu-s390x, kvm, qemu-ppc

On 4/11/26 05:53, Philippe Mathieu-Daudé wrote:
> hmp-target.c doesn't contain any target-specific code anymore.
> Merge it within hmp-cmds.c (which is already built once).
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   MAINTAINERS          |  1 -
>   monitor/hmp-cmds.c   | 40 ++++++++++++++++++++++++
>   monitor/hmp-target.c | 73 --------------------------------------------
>   monitor/meson.build  |  3 --
>   4 files changed, 40 insertions(+), 77 deletions(-)
>   delete mode 100644 monitor/hmp-target.c

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2026-04-13  8:13 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-10 19:52 [PATCH v2 00/27] monitor: Remove need of per-target handlers Philippe Mathieu-Daudé
2026-04-10 19:52 ` [PATCH v2 01/27] monitor: Have MonitorDef::get_value() always return int64_t type Philippe Mathieu-Daudé
2026-04-13  2:42   ` Richard Henderson
2026-04-10 19:52 ` [PATCH v2 02/27] monitor: Remove target_long use in get_monitor_def() Philippe Mathieu-Daudé
2026-04-13  2:54   ` Richard Henderson
2026-04-10 19:52 ` [PATCH v2 03/27] monitor: Reduce target-specific methods further Philippe Mathieu-Daudé
2026-04-13  2:54   ` Richard Henderson
2026-04-10 19:52 ` [PATCH v2 04/27] monitor: Remove 'monitor/hmp-target.h' header Philippe Mathieu-Daudé
2026-04-10 19:52 ` [PATCH v2 05/27] monitor: Forward-declare the MonitorDef type Philippe Mathieu-Daudé
2026-04-13  3:10   ` Richard Henderson
2026-04-10 19:53 ` [PATCH v2 06/27] cpus: Introduce SysemuCPUOps::monitor_defs hook Philippe Mathieu-Daudé
2026-04-10 19:53 ` [PATCH v2 07/27] target/i386: Replace target_monitor_defs -> SysemuCPUOps::monitor_defs Philippe Mathieu-Daudé
2026-04-10 19:53 ` [PATCH v2 08/27] target/m68k: " Philippe Mathieu-Daudé
2026-04-13  3:59   ` Richard Henderson
2026-04-10 19:53 ` [PATCH v2 09/27] target/sparc: " Philippe Mathieu-Daudé
2026-04-10 19:53 ` [PATCH v2 10/27] monitor: Remove target_monitor_defs() Philippe Mathieu-Daudé
2026-04-10 19:53 ` [PATCH v2 11/27] cpus: Introduce SysemuCPUOps::monitor_get_register() hook Philippe Mathieu-Daudé
2026-04-13  4:09   ` Richard Henderson
2026-04-10 19:53 ` [PATCH v2 12/27] target/riscv: Register target_get_monitor_def in SysemuCPUOps Philippe Mathieu-Daudé
2026-04-10 19:53 ` [PATCH v2 13/27] monitor: Remove target_get_monitor_def() Philippe Mathieu-Daudé
2026-04-10 19:53 ` [PATCH v2 14/27] monitor/meson: Use SPICE with migration HMP commands Philippe Mathieu-Daudé
2026-04-10 19:53 ` [PATCH v2 15/27] stubs: Rename monitor* -> qmp* files Philippe Mathieu-Daudé
2026-04-10 19:53 ` [PATCH v2 16/27] monitor: Make 'info via' a generic command Philippe Mathieu-Daudé
2026-04-10 19:53 ` [PATCH v2 17/27] monitor: Make Xen emulation commands generic ones Philippe Mathieu-Daudé
2026-04-10 20:03   ` David Woodhouse
2026-04-10 19:53 ` [PATCH v2 18/27] system: Expose 'arch_init.h' as 'qemu/target-arch-defs.h' Philippe Mathieu-Daudé
2026-04-10 19:53 ` [PATCH v2 19/27] monitor: Introduce HMPCommand::arch_bitmask field Philippe Mathieu-Daudé
2026-04-13  4:41   ` Richard Henderson
2026-04-10 19:53 ` [PATCH v2 20/27] hw/s390x: Reduce 'monitor/monitor.h' inclusions Philippe Mathieu-Daudé
2026-04-13  8:08   ` Cornelia Huck
2026-04-10 19:53 ` [PATCH v2 21/27] monitor: Do not check TARGET_S390X to build s390x commands Philippe Mathieu-Daudé
2026-04-13  8:10   ` Cornelia Huck
2026-04-10 19:53 ` [PATCH v2 22/27] monitor: Do not check TARGET_I386 to build target/i386/ commands Philippe Mathieu-Daudé
2026-04-10 19:53 ` [PATCH v2 23/27] monitor: Do not check TARGET_I386 to build 'info sgx' command Philippe Mathieu-Daudé
2026-04-10 19:53 ` [PATCH v2 24/27] monitor: Do not check TARGET_I386 to build 'info sev' command Philippe Mathieu-Daudé
2026-04-10 19:53 ` [PATCH v2 25/27] monitor: Do not check TARGET_I386/RISCV to build 'info mem' command Philippe Mathieu-Daudé
2026-04-10 19:53 ` [PATCH v2 26/27] monitor: Do not check multiple TARGET_* to build 'info tlb' command Philippe Mathieu-Daudé
2026-04-10 19:53 ` [PATCH v2 27/27] monitor: Merge hmp-target.c code within hmp-cmds.c Philippe Mathieu-Daudé
2026-04-13  8:13   ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox