From f0e48cbd791e88728fcea65366dbb6d9a63a16e5 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 24 Jun 2021 12:38:32 +0200 Subject: 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 Reviewed-by: Jose R. Ziviani Message-Id: <20210624103836.2382472-31-kraxel@redhat.com> Signed-off-by: Paolo Bonzini --- monitor/hmp.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'monitor/hmp.c') 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])) { -- cgit v1.2.3