From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tt8qh-0003Oe-Ai for qemu-devel@nongnu.org; Wed, 09 Jan 2013 22:30:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tt8qf-00061r-Mk for qemu-devel@nongnu.org; Wed, 09 Jan 2013 22:30:35 -0500 Received: from e28smtp03.in.ibm.com ([122.248.162.3]:51218) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tt8qf-00061W-3H for qemu-devel@nongnu.org; Wed, 09 Jan 2013 22:30:33 -0500 Received: from /spool/local by e28smtp03.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Jan 2013 08:59:18 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id F325A394004D for ; Thu, 10 Jan 2013 09:00:27 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r0A3UPOF35520548 for ; Thu, 10 Jan 2013 09:00:25 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r0A3UQ3N026775 for ; Thu, 10 Jan 2013 14:30:26 +1100 Message-ID: <50EE35C9.8010904@linux.vnet.ibm.com> Date: Thu, 10 Jan 2013 11:30:17 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1356601227-8707-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1356601227-8707-3-git-send-email-xiawenc@linux.vnet.ibm.com> <20130109105758.47a2923b@doriath.home> In-Reply-To: <20130109105758.47a2923b@doriath.home> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH V3 2/4] HMP: add infrastructure for sub command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: pbonzini@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org, chenwj@iis.sinica.edu.tw, armbru@redhat.com >> -static const mon_cmd_t *qmp_find_cmd(const char *cmdname) >> -{ >> - return search_dispatch_table(qmp_cmds, cmdname); >> -} > > Touching qmp_find_cmd() is unrelated to this series. > OK. >> - >> -static const mon_cmd_t *monitor_parse_command(Monitor *mon, >> - const char *cmdline, >> - QDict *qdict) >> +/* >> + * Try find the target mon_cmd_t instance, if it have sub_table and have string >> + * for it, this function will try search it with remain string, and if not >> + * found it return NULL. >> + */ >> +static const mon_cmd_t *hmp_parse_command(Monitor *mon, >> + const char *cmdline, >> + mon_cmd_t *table, >> + QDict *qdict) > > Renaming is also not necessary, but if you do it please do in a different > patch. > OK. >> { >> + } >> + return hmp_parse_command(mon, p, cmd->sub_table, qdict); > > This works, and seems less hack then the previous attempt. > > Except for a small detail. This: > > (qemu) info bla > > Currently returns a list of info commands, but with this series it returns > an error. > Yep, I think command completion is another topic, but I am pretty sure it can be solved in this framework, for that it is not hack and what need to do is, let command completion function knows there may be another sub layer too. > I'd like to get a reviewed-by from Markus before applying this as, besides > this being his idea, I honestly have a very hard time knowing how to move old > hmp hackery forward. > >> + } >> + >> /* parse the parameters */ >> typestr = cmd->args_type; >> for(;;) { >> @@ -3925,7 +3935,7 @@ static void handle_user_command(Monitor *mon, const char *cmdline) >> >> qdict = qdict_new(); >> >> - cmd = monitor_parse_command(mon, cmdline, qdict); >> + cmd = hmp_parse_command(mon, cmdline, mon_cmds, qdict); >> if (!cmd) >> goto out; >> >> @@ -4483,7 +4493,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) >> goto err_out; >> } >> >> - cmd = qmp_find_cmd(cmd_name); >> + cmd = search_dispatch_table(qmp_cmds, cmd_name); >> if (!cmd) { >> qerror_report(QERR_COMMAND_NOT_FOUND, cmd_name); >> goto err_out; > > -- Best Regards Wenchao Xia