From patchwork Thu Dec 10 14:43:21 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 40812 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 A5724B6F01 for ; Fri, 11 Dec 2009 01:55:59 +1100 (EST) Received: from localhost ([127.0.0.1]:57356 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIkQu-0002Wb-Ls for incoming@patchwork.ozlabs.org; Thu, 10 Dec 2009 09:55:56 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NIkFP-0001KX-AP for qemu-devel@nongnu.org; Thu, 10 Dec 2009 09:44:03 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NIkFK-0001Hd-F4 for qemu-devel@nongnu.org; Thu, 10 Dec 2009 09:44:02 -0500 Received: from [199.232.76.173] (port=45372 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIkFK-0001HU-1g for qemu-devel@nongnu.org; Thu, 10 Dec 2009 09:43:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:13043) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NIkFK-0004D8-1Q for qemu-devel@nongnu.org; Thu, 10 Dec 2009 09:43:58 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBAEhuc9022417 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 10 Dec 2009 09:43:56 -0500 Received: from localhost (vpn-11-77.rdu.redhat.com [10.11.11.77]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBAEhtPe001434; Thu, 10 Dec 2009 09:43:56 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 10 Dec 2009 12:43:21 -0200 Message-Id: <1260456215-31022-7-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1260456215-31022-1-git-send-email-lcapitulino@redhat.com> References: <1260456215-31022-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 06/20] monitor: Fix do_info_commands() output 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 Should return a QDict and should not print the user protocol bits (eg. "c|cont"). Signed-off-by: Luiz Capitulino --- monitor.c | 30 +++++++++++++++++++++++++++--- 1 files changed, 27 insertions(+), 3 deletions(-) diff --git a/monitor.c b/monitor.c index aa56ec7..5010ce4 100644 --- a/monitor.c +++ b/monitor.c @@ -518,10 +518,34 @@ static void do_info_name(Monitor *mon) monitor_printf(mon, "%s\n", qemu_name); } +static QObject *get_cmd_dict(const char *name) +{ + const char *p; + + /* Remove '|' from some commands */ + p = strchr(name, '|'); + if (p) { + p++; + } else { + p = name; + } + + return qobject_from_jsonf("{ 'name': %s }", p); +} + /** * do_info_commands(): List QMP available commands * - * Return a QList of QStrings. + * Each command is represented by a QDict, the returned QObject is a QList + * of all commands. + * + * The QDict contains: + * + * - "name": command's name + * + * Example: + * + * { [ { "name": "query-balloon" }, { "name": "system_powerdown" } ] } */ static void do_info_commands(Monitor *mon, QObject **ret_data) { @@ -532,7 +556,7 @@ static void do_info_commands(Monitor *mon, QObject **ret_data) for (cmd = mon_cmds; cmd->name != NULL; cmd++) { if (monitor_handler_ported(cmd) && !compare_cmd(cmd->name, "info")) { - qlist_append(cmd_list, qstring_from_str(cmd->name)); + qlist_append_obj(cmd_list, get_cmd_dict(cmd->name)); } } @@ -540,7 +564,7 @@ static void do_info_commands(Monitor *mon, QObject **ret_data) if (monitor_handler_ported(cmd)) { char buf[128]; snprintf(buf, sizeof(buf), "query-%s", cmd->name); - qlist_append(cmd_list, qstring_from_str(buf)); + qlist_append_obj(cmd_list, get_cmd_dict(buf)); } }