From patchwork Mon May 7 14:30:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Collin Walling X-Patchwork-Id: 10384251 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0CE4A6037F for ; Mon, 7 May 2018 14:33:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3FB320072 for ; Mon, 7 May 2018 14:33:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E834D28B7F; Mon, 7 May 2018 14:33:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5775828D1A for ; Mon, 7 May 2018 14:32:04 +0000 (UTC) Received: from localhost ([::1]:46574 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fFhBL-0001iP-JE for patchwork-qemu-devel@patchwork.kernel.org; Mon, 07 May 2018 10:32:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fFhAN-00019B-Ly for qemu-devel@nongnu.org; Mon, 07 May 2018 10:31:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fFhAK-0007xQ-JV for qemu-devel@nongnu.org; Mon, 07 May 2018 10:31:03 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:43600) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fFhAK-0007wu-9r for qemu-devel@nongnu.org; Mon, 07 May 2018 10:31:00 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w47ETcXf043259 for ; Mon, 7 May 2018 10:30:59 -0400 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0a-001b2d01.pphosted.com with ESMTP id 2htqx323de-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 07 May 2018 10:30:58 -0400 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 7 May 2018 10:30:57 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 7 May 2018 10:30:55 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w47EUttn42336442; Mon, 7 May 2018 14:30:55 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5ED1A12403F; Mon, 7 May 2018 11:32:52 -0400 (EDT) Received: from [9.56.58.146] (unknown [9.56.58.146]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 51EDF12403D; Mon, 7 May 2018 11:32:52 -0400 (EDT) From: Collin Walling To: Eric Blake , qemu-devel@nongnu.org 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> Organization: IBM Date: Mon, 7 May 2018 10:30:54 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <724592be-f5ac-7a40-8c26-5d2dd200ef82@linux.ibm.com> Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18050714-0048-0000-0000-00000269712C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008987; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000258; SDB=6.01028845; UDB=6.00525670; IPR=6.00807978; MB=3.00020971; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-07 14:30:56 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050714-0049-0000-0000-000045091E2B Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-07_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805070148 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: Re: [Qemu-devel] [PATCH v2] monitor: report entirety of hmp command on error X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Eric Blake --- 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; }