From patchwork Fri May 4 14:49:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Collin Walling X-Patchwork-Id: 908809 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40cw1J1G8rz9s3G for ; Sat, 5 May 2018 00:50:42 +1000 (AEST) Received: from localhost ([::1]:34724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEc2h-00028O-Bc for incoming@patchwork.ozlabs.org; Fri, 04 May 2018 10:50:39 -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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 skeys", only the last whitespace delimited string will be reported (in this example "info" will 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 through the function monitor_parse_command. Reported-by: Mikhail Fokin Signed-off-by: Collin Walling 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 mon_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(Monitor *mon, p++; } + strncat(fullname, cmdname, strlen(cmdname)); + *cmdp = p; /* search sub command */ if (cmd->sub_table != NULL && *p != '\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); } 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]; trace_handle_hmp_command(mon, cmdline); - cmd = monitor_parse_command(mon, cmdline, &cmdline, mon->cmd_table); + cmd = 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 char *cmdline) qdict = monitor_parse_arguments(mon, &cmdline, cmd); if (!qdict) { monitor_printf(mon, "Try \"help %s\" for more information\n", - cmd->name); + fullname); return; }