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