From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNy8M-0001Ef-AJ for qemu-devel@nongnu.org; Wed, 30 May 2018 06:15:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNy8I-0001JD-DD for qemu-devel@nongnu.org; Wed, 30 May 2018 06:15:10 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38150 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fNy8I-0001IM-9I for qemu-devel@nongnu.org; Wed, 30 May 2018 06:15:06 -0400 Date: Wed, 30 May 2018 11:15:02 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20180530101502.GA2410@work-vm> References: <1525445354-16233-1-git-send-email-walling@linux.ibm.com> <7e9e9dfd-795b-47f2-453a-59bf65f28229@redhat.com> <7274b001-02f2-6584-ea0a-c3d0f96d46b8@linux.ibm.com> <89dc884d-97af-4922-bd69-1cb7308399d8@redhat.com> <724592be-f5ac-7a40-8c26-5d2dd200ef82@linux.ibm.com> <87y3g916lq.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87y3g916lq.fsf@dusky.pond.sub.org> Subject: Re: [Qemu-devel] [PATCH v2] monitor: report entirety of hmp command on error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Eric Blake , qemu-devel@nongnu.org, Collin Walling * Markus Armbruster (armbru@redhat.com) wrote: > David, looks like your turf. Yep, I've got it on my list to take. Dave > Collin Walling writes: > > > When a user incorrectly provides an hmp command, an error response will be > > printed that prompts the user to try "help ". 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 > > Signed-off-by: Collin Walling > > --- > > 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; > > } -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK