aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorCollin Walling <walling@linux.ibm.com>2018-05-07 10:30:54 -0400
committerDr. David Alan Gilbert <dgilbert@redhat.com>2018-06-21 12:18:35 +0100
commit317c52cc6aa0d7b47fa156eb84857a339d0b4406 (patch)
tree376ce35e6736828fb92199a7913d0741d96e719f /monitor.c
parent46012db666990ff2eed1d3dc199ab8006439a93b (diff)
monitor: report entirety of hmp command on error
When a user incorrectly provides an hmp command, an error response will be printed that prompts the user to try "help <command name>". However, when the command contains multiple parts e.g. "info uuid xyz", only the last whitespace delimited string will be reported (in this example "info" will be dropped and the message will read "Try "help uuid" for more information", which is incorrect). Let's correct this by capturing the entirety of the command from the command line -- excluding any extraneous characters. Reported-by: Mikhail Fokin <fokin@de.ibm.com> Signed-off-by: Collin Walling <walling@linux.ibm.com> Message-Id: <ee680f5e-ac9a-479d-f65e-9f8ae9cfe5d4@linux.ibm.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/monitor.c b/monitor.c
index 885e000f9b..2a8187f5d7 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3431,6 +3431,7 @@ static void handle_hmp_command(Monitor *mon, const char *cmdline)
{
QDict *qdict;
const mon_cmd_t *cmd;
+ const char *cmd_start = cmdline;
trace_handle_hmp_command(mon, cmdline);
@@ -3447,8 +3448,11 @@ static void handle_hmp_command(Monitor *mon, const char *cmdline)
qdict = monitor_parse_arguments(mon, &cmdline, cmd);
if (!qdict) {
- monitor_printf(mon, "Try \"help %s\" for more information\n",
- cmd->name);
+ while (cmdline > cmd_start && qemu_isspace(cmdline[-1])) {
+ cmdline--;
+ }
+ monitor_printf(mon, "Try \"help %.*s\" for more information\n",
+ (int)(cmdline - cmd_start), cmd_start);
return;
}