monitor: Introduce HMPCommand::arch_bitmask field
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> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20260427080738.77138-12-philmd@linaro.org>
Philippe Mathieu-Daudé committed
Apr 10, 2026 at 16:09 UTC
c15fec4a00eb994d0b64ee2c1ce99f23af263495
3 files changed
+15
-1
monitor/hmp-target.c
+1
@@ -23,6 +23,7 @@
23
*/
24
25
#include "qemu/osdep.h"
26
+#include "qemu/base-arch-defs.h"
27
#include "monitor-internal.h"
28
#include "monitor/qdev.h"
29
#include "net/slirp.h"
monitor/hmp.c
+4
@@ -36,6 +36,7 @@
36
#include "qemu/cutils.h"
37
#include "qemu/log.h"
38
#include "qemu/option.h"
39
+#include "qemu/base-arch-defs.h"
40
#include "qemu/target-info.h"
41
#include "qemu/units.h"
42
#include "exec/gdbstub.h"
@@ -219,6 +220,9 @@ static bool cmd_can_preconfig(const HMPCommand *cmd)
220
221
static bool cmd_available(const HMPCommand *cmd)
222
{
223
+ if (cmd->arch_bitmask && !qemu_arch_available(cmd->arch_bitmask)) {
224
+ return false;
225
+ }
226
return phase_check(PHASE_MACHINE_READY) || cmd_can_preconfig(cmd);
227
}
228
monitor/monitor-internal.h
+10
-1
@@ -82,7 +82,6 @@ typedef struct HMPCommand {
82
* the formatted text.
83
*/
84
HumanReadableText *(*cmd_info_hrt)(Error **errp);
85
- bool coroutine;
85
/*
86
* @sub_table is a list of 2nd level of commands. If it does not exist,
87
* cmd should be used. If it exists, sub_table[?].cmd should be
@@ -90,6 +89,16 @@ typedef struct HMPCommand {
89
*/
90
struct HMPCommand *sub_table;
91
void (*command_completion)(ReadLineState *rs, int nb_args, const char *str);
92
+
93
+ /* Keep non-pointer data at the end to minimize holes. */
94
+
95
+ /**
96
+ * @arch_bitmask: bitmask of QEMU_ARCH_* constants
97
+ * Allow to restrict the command for a particular set of
98
+ * target architectures.
99
+ */
100
+ uint32_t arch_bitmask;
101
+ bool coroutine;
102
} HMPCommand;
103
104
struct Monitor {