From patchwork Thu Jan 17 15:12:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 213296 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 CFABC2C0079 for ; Fri, 18 Jan 2013 02:13:27 +1100 (EST) Received: from localhost ([::1]:43867 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tvr9h-0004fF-KO for incoming@patchwork.ozlabs.org; Thu, 17 Jan 2013 10:13:25 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tvr98-0003YV-7g for qemu-devel@nongnu.org; Thu, 17 Jan 2013 10:12:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tvr97-0003OH-0s for qemu-devel@nongnu.org; Thu, 17 Jan 2013 10:12:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tvr96-0003OC-PK for qemu-devel@nongnu.org; Thu, 17 Jan 2013 10:12:48 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0HFCmVK028893 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 17 Jan 2013 10:12:48 -0500 Received: from localhost (ovpn-113-70.phx2.redhat.com [10.3.113.70]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0HFCjtP030327; Thu, 17 Jan 2013 10:12:47 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 17 Jan 2013 13:12:30 -0200 Message-Id: <1358435550-502-6-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1358435550-502-1-git-send-email-lcapitulino@redhat.com> References: <1358435550-502-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PULL 5/5] 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 From: Wenchao Xia Now info command takes a table of sub info commands, and changed do_info() to do_info_help() to do help funtion only. Note that now "info " returns error instead of list of info topics. Signed-off-by: Wenchao Xia Signed-off-by: Luiz Capitulino --- hmp-commands.hx | 3 ++- monitor.c | 22 +--------------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 67569ef..0934b9b 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1521,7 +1521,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 ef1b7ac..20bd19b 100644 --- a/monitor.c +++ b/monitor.c @@ -811,28 +811,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.cmd(mon, NULL); - return; - -help: help_cmd(mon, "info"); }