qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] monitor: report entirety of hmp command on e


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v2] monitor: report entirety of hmp command on error
Date: Thu, 24 May 2018 16:16:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

David, looks like your turf.

Collin Walling <address@hidden> writes:

> 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 <address@hidden>
> Signed-off-by: Collin Walling <address@hidden>
> ---
>  monitor.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 39f8ee1..38736b3 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -3371,6 +3371,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);
>  
> @@ -3381,8 +3382,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;
>      }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]