mirror of
https://github.com/qemu/qemu.git
synced 2024-11-25 03:43:37 +08:00
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>
This commit is contained in:
parent
46012db666
commit
317c52cc6a
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user