monitor: Do not check TARGET_S390X to build s390x commands
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> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Acked-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Eric Farman <farman@linux.ibm.com> Message-Id: <20260427080738.77138-14-philmd@linaro.org>
Philippe Mathieu-Daudé committed
Apr 10, 2026 at 19:25 UTC
1d6cf922e4a5285f3bd0ddc2242d74a213f06530
7 files changed
+28
-13
MAINTAINERS
+1
@@ -122,6 +122,7 @@ F: include/hw/watchdog/wdt_diag288.h
122
F: pc-bios/s390-ccw/
123
F: pc-bios/s390-ccw.img
124
F: stubs/qmp-cpu-s390x.c
125
+F: stubs/hmp-cmds-hw-s390x.c
126
F: target/s390x/
127
F: docs/system/target-s390x.rst
128
F: docs/system/s390x/
hmp-commands-info.hx
+2
-4
@@ -710,30 +710,28 @@ SRST
710
Show rocker OF-DPA groups.
711
ERST
712
713
-#if defined(TARGET_S390X)
713
{
714
.name = "skeys",
715
.args_type = "addr:l",
716
.params = "address",
717
.help = "Display the value of a storage key",
718
.cmd = hmp_info_skeys,
719
+ .arch_bitmask = QEMU_ARCH_S390X,
720
},
721
-#endif
721
722
SRST
723
``info skeys`` *address*
724
Display the value of a storage key (s390 only)
725
ERST
726
728
-#if defined(TARGET_S390X)
727
{
728
.name = "cmma",
729
.args_type = "addr:l,count:l?",
730
.params = "address [count]",
731
.help = "Display the values of the CMMA storage attributes for a range of pages",
732
.cmd = hmp_info_cmma,
733
+ .arch_bitmask = QEMU_ARCH_S390X,
734
},
736
-#endif
735
736
SRST
737
``info cmma`` *address*
hmp-commands.hx
+2
-4
@@ -1139,30 +1139,28 @@ SRST
1139
1140
ERST
1141
1142
-#if defined(TARGET_S390X)
1142
{
1143
.name = "dump-skeys",
1144
.args_type = "filename:F",
1145
.params = "",
1146
.help = "Save guest storage keys into file 'filename'.\n",
1147
.cmd = hmp_dump_skeys,
1148
+ .arch_bitmask = QEMU_ARCH_S390X,
1149
},
1150
-#endif
1150
1151
SRST
1152
``dump-skeys`` *filename*
1153
Save guest storage keys to a file.
1154
ERST
1155
1157
-#if defined(TARGET_S390X)
1156
{
1157
.name = "migration_mode",
1158
.args_type = "mode:i",
1159
.params = "mode",
1160
.help = "Enables or disables migration mode\n",
1161
.cmd = hmp_migrationmode,
1162
+ .arch_bitmask = QEMU_ARCH_S390X,
1163
},
1165
-#endif
1164
1165
SRST
1166
``migration_mode`` *mode*
include/monitor/hmp.h
+7
@@ -16,6 +16,13 @@
16
17
#include "qemu/readline.h"
18
#include "qapi/qapi-types-common.h"
19
+#include "monitor/monitor.h"
20
+
21
+#define HMP_STUB(cmd) \
22
+ void hmp_##cmd(Monitor *mon, const QDict *qdict) \
23
+ { \
24
+ g_assert_not_reached(); \
25
+ }
26
27
bool hmp_handle_error(Monitor *mon, Error *err);
28
void hmp_help_cmd(Monitor *mon, const char *name);
monitor/hmp-target.c
-5
@@ -36,11 +36,6 @@
36
#include "qapi/qapi-commands-misc.h"
37
#include "qapi/qapi-commands-machine.h"
38
39
-#if defined(TARGET_S390X)
40
-#include "hw/s390x/storage-keys.h"
41
-#include "hw/s390x/storage-attributes.h"
42
-#endif
43
-
39
/* Make devices configuration available for use in hmp-commands*.hx templates */
40
#include CONFIG_DEVICES
41
stubs/hmp-cmds-hw-s390x.c
new
+15
@@ -0,0 +1,15 @@
1
+/*
2
+ * Human Monitor hw/s390x stubs
3
+ *
4
+ * Copyright (c) Linaro
5
+ *
6
+ * SPDX-License-Identifier: GPL-2.0-or-later
7
+ */
8
+
9
+#include "qemu/osdep.h"
10
+#include "monitor/hmp.h"
11
+
12
+HMP_STUB(dump_skeys)
13
+HMP_STUB(info_cmma)
14
+HMP_STUB(info_skeys)
15
+HMP_STUB(migrationmode)
stubs/meson.build
+1
@@ -87,6 +87,7 @@ if have_system
87
stub_ss.add(files('qmp-cpu.c'))
88
stub_ss.add(files('qmp-cpu-s390x.c'))
89
stub_ss.add(files('qmp-cpu-s390x-kvm.c'))
90
+ stub_ss.add(files('hmp-cmds-hw-s390x.c'))
91
endif
92
93
if have_system or have_user