From patchwork Thu Oct 21 06:37:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 68524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 837551007D4 for ; Thu, 21 Oct 2010 17:44:01 +1100 (EST) Received: from localhost ([127.0.0.1]:55653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8osY-0000tf-EF for incoming@patchwork.ozlabs.org; Thu, 21 Oct 2010 02:43:58 -0400 Received: from [140.186.70.92] (port=44598 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8omH-0006Js-5D for qemu-devel@nongnu.org; Thu, 21 Oct 2010 02:37:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8omC-0001al-7O for qemu-devel@nongnu.org; Thu, 21 Oct 2010 02:37:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13278) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8omC-0001aX-0w for qemu-devel@nongnu.org; Thu, 21 Oct 2010 02:37:24 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9L6bNRI020980 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 21 Oct 2010 02:37:23 -0400 Received: from playa.redhat.com (vpn-6-82.tlv.redhat.com [10.35.6.82]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9L6bKDe006086 for ; Thu, 21 Oct 2010 02:37:22 -0400 From: Alon Levy To: qemu-devel@nongnu.org Date: Thu, 21 Oct 2010 08:37:19 +0200 Message-Id: <1287643040-21200-2-git-send-email-alevy@redhat.com> In-Reply-To: <1287643040-21200-1-git-send-email-alevy@redhat.com> References: <1287643040-21200-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 1/2] monitor: add sub_args_type for second level parameters X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org --- hmp-commands.hx | 1 + monitor.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 3014b17..289fbcb 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1158,6 +1158,7 @@ ETEXI .args_type = "item:s?", .params = "[subcommand]", .help = "show various information about the system state", + .sub_args_type = do_info_sub_args_type, .mhandler.cmd = do_info, }, diff --git a/monitor.c b/monitor.c index 260cc02..7d1d3b1 100644 --- a/monitor.c +++ b/monitor.c @@ -107,6 +107,7 @@ typedef struct mon_cmd_t { const char *params; const char *help; void (*user_print)(Monitor *mon, const QObject *data); + const char *(*sub_args_type)(const QDict *qdict); union { void (*info)(Monitor *mon); void (*info_new)(Monitor *mon, QObject **ret_data); @@ -3500,6 +3501,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, char cmdname[256]; char buf[1024]; char *key; + int did_sub_args_type = 0; #ifdef DEBUG monitor_printf(mon, "command='%s'\n", cmdline); @@ -3520,8 +3522,17 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, typestr = cmd->args_type; for(;;) { typestr = key_get_info(typestr, &key); - if (!typestr) + /* Allow for two level parameters definition. Call sub_args_type only + * after finished parsing existing args */ + if (!typestr && cmd->sub_args_type != NULL && !did_sub_args_type) { + if ((typestr = cmd->sub_args_type(qdict)) != NULL) { + typestr = key_get_info(typestr, &key); + } + did_sub_args_type = 1; + } + if (!typestr) { break; + } c = *typestr; typestr++; switch(c) {