From patchwork Thu Dec 27 08:56:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 208284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7479B2C008A for ; Thu, 27 Dec 2012 19:59:08 +1100 (EST) Received: from localhost ([::1]:55754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1To9Iw-0002qR-Ol for incoming@patchwork.ozlabs.org; Thu, 27 Dec 2012 03:59:06 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1To9IC-0000x6-DS for qemu-devel@nongnu.org; Thu, 27 Dec 2012 03:58:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1To9IB-0004in-93 for qemu-devel@nongnu.org; Thu, 27 Dec 2012 03:58:20 -0500 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:60214) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1To9IA-0004iU-Kp for qemu-devel@nongnu.org; Thu, 27 Dec 2012 03:58:19 -0500 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 27 Dec 2012 14:27:18 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp06.in.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 27 Dec 2012 14:27:15 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id F1EE5E004C for ; Thu, 27 Dec 2012 14:28:11 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qBR8wBHj44367922 for ; Thu, 27 Dec 2012 14:28:11 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qBR8wBx2014546 for ; Thu, 27 Dec 2012 08:58:11 GMT Received: from RedHat62GAWSWenchao (wenchaox.cn.ibm.com [9.115.122.122] (may be forged)) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id qBR8uGAZ005439; Thu, 27 Dec 2012 08:58:10 GMT From: Wenchao Xia To: qemu-devel@nongnu.org Date: Thu, 27 Dec 2012 16:56:29 +0800 Message-Id: <1356598589-5744-4-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1356598589-5744-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1356598589-5744-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12122708-9574-0000-0000-000005F1B7C5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.6 Cc: aliguori@us.ibm.com, armbru@redhat.com, lcapitulino@redhat.com, pbonzini@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V2 3/3] HMP: add sub command table to info X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 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-bounces+incoming=patchwork.ozlabs.org@nongnu.org Now info command takes a table of sub info commands, and changed do_info() to do_info_help() to do help funtion only. Signed-off-by: Wenchao Xia --- hmp-commands.hx | 3 ++- monitor.c | 34 +++++++--------------------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 010b8c9..87a411a 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1489,7 +1489,8 @@ ETEXI .args_type = "item:s?", .params = "[subcommand]", .help = "show various information about the system state", - .mhandler.cmd = do_info, + .mhandler.cmd = do_info_help, + .sub_table = info_cmds, }, STEXI diff --git a/monitor.c b/monitor.c index e4d4c59..e1bcaa2 100644 --- a/monitor.c +++ b/monitor.c @@ -807,28 +807,8 @@ static void user_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd, } } -static void do_info(Monitor *mon, const QDict *qdict) +static void do_info_help(Monitor *mon, const QDict *qdict) { - const mon_cmd_t *cmd; - const char *item = qdict_get_try_str(qdict, "item"); - - if (!item) { - goto help; - } - - for (cmd = info_cmds; cmd->name != NULL; cmd++) { - if (compare_cmd(item, cmd->name)) - break; - } - - if (cmd->name == NULL) { - goto help; - } - - cmd->mhandler.info(mon, NULL); - return; - -help: help_cmd(mon, "info"); } @@ -2422,12 +2402,6 @@ int monitor_handle_fd_param(Monitor *mon, const char *fdname) return fd; } -/* mon_cmds and info_cmds would be sorted at runtime */ -static mon_cmd_t mon_cmds[] = { -#include "hmp-commands.h" - { NULL, NULL, }, -}; - /* Please update hmp-commands.hx when adding or changing commands */ static mon_cmd_t info_cmds[] = { { @@ -2741,6 +2715,12 @@ static mon_cmd_t info_cmds[] = { }, }; +/* mon_cmds and info_cmds would be sorted at runtime */ +static mon_cmd_t mon_cmds[] = { +#include "hmp-commands.h" + { NULL, NULL, }, +}; + static const mon_cmd_t qmp_cmds[] = { #include "qmp-commands-old.h" { /* NULL */ },