From nobody Wed Oct 29 09:15:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1525445486726160.19377022557808; Fri, 4 May 2018 07:51:26 -0700 (PDT) Received: from localhost ([::1]:34730 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEc3I-0002Wo-Q5 for importer@patchew.org; Fri, 04 May 2018 10:51:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEc2L-00028G-1Y for qemu-devel@nongnu.org; Fri, 04 May 2018 10:50:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEc2H-0006L7-Ux for qemu-devel@nongnu.org; Fri, 04 May 2018 10:50:17 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58112) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fEc2H-0006Jm-Ls for qemu-devel@nongnu.org; Fri, 04 May 2018 10:50:13 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w44Eo75k075438 for ; Fri, 4 May 2018 10:50:11 -0400 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hrqemeejw-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 04 May 2018 10:50:10 -0400 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 4 May 2018 10:50:09 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 4 May 2018 10:50:06 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w44Eo5Af49479866 for ; Fri, 4 May 2018 14:50:05 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E0410112040 for ; Fri, 4 May 2018 10:49:53 -0400 (EDT) Received: from collin-ThinkPad-W541.ibm.com (unknown [9.80.203.234]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id C3521112034 for ; Fri, 4 May 2018 10:49:53 -0400 (EDT) From: Collin Walling To: qemu-devel@nongnu.org Date: Fri, 4 May 2018 10:49:14 -0400 X-Mailer: git-send-email 2.7.4 X-TM-AS-GCONF: 00 x-cbid: 18050414-0008-0000-0000-00000302CAA0 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008969; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000258; SDB=6.01027411; UDB=6.00524812; IPR=6.00806544; MB=3.00020928; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-04 14:50:07 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050414-0009-0000-0000-00003921D7A2 Message-Id: <1525445354-16233-1-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-04_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805040137 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When a user incorrectly provides an hmp command, an error response will be=20 printed that prompts the user to try "help ". However, when the command contains multiple parts e.g. "info skeys", only the last=20 whitespace delimited string will be reported (in this example "info" will=20 be dropped and the message will read "Try "help skeys" for more information= ", which is incorrect). Let's correct this by capturing the full name of the command as we recurse=20 through the function monitor_parse_command. Reported-by: Mikhail Fokin Signed-off-by: Collin Walling Reviewed-by: Eric Blake --- monitor.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/monitor.c b/monitor.c index 39f8ee1..d4844b4 100644 --- a/monitor.c +++ b/monitor.c @@ -2964,7 +2964,8 @@ static const mon_cmd_t *search_dispatch_table(const m= on_cmd_t *disp_table, static const mon_cmd_t *monitor_parse_command(Monitor *mon, const char *cmdp_start, const char **cmdp, - mon_cmd_t *table) + mon_cmd_t *table, + char *fullname) { const char *p; const mon_cmd_t *cmd; @@ -2987,10 +2988,14 @@ static const mon_cmd_t *monitor_parse_command(Monit= or *mon, p++; } =20 + strncat(fullname, cmdname, strlen(cmdname)); + *cmdp =3D p; /* search sub command */ if (cmd->sub_table !=3D NULL && *p !=3D '\0') { - return monitor_parse_command(mon, cmdp_start, cmdp, cmd->sub_table= ); + strncat(fullname, " ", 1); + return monitor_parse_command(mon, cmdp_start, cmdp, cmd->sub_table, + fullname); } =20 return cmd; @@ -3371,10 +3376,12 @@ static void handle_hmp_command(Monitor *mon, const = char *cmdline) { QDict *qdict; const mon_cmd_t *cmd; + char fullname[256]; =20 trace_handle_hmp_command(mon, cmdline); =20 - cmd =3D monitor_parse_command(mon, cmdline, &cmdline, mon->cmd_table); + cmd =3D monitor_parse_command(mon, cmdline, &cmdline, mon->cmd_table, + fullname); if (!cmd) { return; } @@ -3382,7 +3389,7 @@ static void handle_hmp_command(Monitor *mon, const ch= ar *cmdline) qdict =3D monitor_parse_arguments(mon, &cmdline, cmd); if (!qdict) { monitor_printf(mon, "Try \"help %s\" for more information\n", - cmd->name); + fullname); return; } =20 --=20 2.7.4