]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
monitor: Introduce HMPCommand::arch_bitmask field
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Fri, 10 Apr 2026 14:09:02 +0000 (16:09 +0200)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Wed, 6 May 2026 10:58:08 +0000 (12:58 +0200)
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>

monitor/hmp-target.c
monitor/hmp.c
monitor/monitor-internal.h

index da7dd7f31f201ecb2bf58792049691b28b25b216..f6dce326cf5a4b589e53830487e5d9efd90a9d65 100644 (file)
@@ -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"
index 0e5913fabb1dfb0c3197a8c809c76ca210f8121b..e881c26c305c988858af7a0cab0e7907040641f4 100644 (file)
@@ -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);
 }
 
index 80b4a8150bf838c3a2d4b1ffeefa5df9e1f70d34..eaf9a60778397fa79952aa557828fd9697eabf6c 100644 (file)
@@ -82,7 +82,6 @@ typedef struct HMPCommand {
      * the formatted text.
      */
     HumanReadableText *(*cmd_info_hrt)(Error **errp);
-    bool coroutine;
     /*
      * @sub_table is a list of 2nd level of commands. If it does not exist,
      * cmd should be used. If it exists, sub_table[?].cmd should be
@@ -90,6 +89,16 @@ typedef struct HMPCommand {
      */
     struct HMPCommand *sub_table;
     void (*command_completion)(ReadLineState *rs, int nb_args, const char *str);
+
+    /* Keep non-pointer data at the end to minimize holes. */
+
+    /**
+     * @arch_bitmask: bitmask of QEMU_ARCH_* constants
+     *     Allow to restrict the command for a particular set of
+     *     target architectures.
+     */
+    uint32_t arch_bitmask;
+    bool coroutine;
 } HMPCommand;
 
 struct Monitor {