summary refs log tree commit diff stats
path: root/monitor/hmp.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2021-06-24 12:38:32 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2021-07-09 18:21:33 +0200
commitf0e48cbd791e88728fcea65366dbb6d9a63a16e5 (patch)
treec8bf882d378d93dc931d31f05bf8043d096b82e7 /monitor/hmp.c
parentdae0ec159f92050026961656e9b7ded1e72758a4 (diff)
downloadfocaccia-qemu-f0e48cbd791e88728fcea65366dbb6d9a63a16e5.tar.gz
focaccia-qemu-f0e48cbd791e88728fcea65366dbb6d9a63a16e5.zip
monitor: allow register hmp commands
Allow commands having a NULL cmd pointer, add a function to set the
pointer later.  Use case: allow modules implement hmp commands.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jose R. Ziviani <jziviani@suse.de>
Message-Id: <20210624103836.2382472-31-kraxel@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'monitor/hmp.c')
-rw-r--r--monitor/hmp.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/monitor/hmp.c b/monitor/hmp.c
index 6c0b33a0b1..d50c3124e1 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -1089,6 +1089,13 @@ void handle_hmp_command(MonitorHMP *mon, const char *cmdline)
         return;
     }
 
+    if (!cmd->cmd) {
+        /* FIXME: is it useful to try autoload modules here ??? */
+        monitor_printf(&mon->common, "Command \"%.*s\" is not available.\n",
+                       (int)(cmdline - cmd_start), cmd_start);
+        return;
+    }
+
     qdict = monitor_parse_arguments(&mon->common, &cmdline, cmd);
     if (!qdict) {
         while (cmdline > cmd_start && qemu_isspace(cmdline[-1])) {