From patchwork Thu Dec 10 19:15:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 40874 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 3AC81B6F12 for ; Fri, 11 Dec 2009 06:32:01 +1100 (EST) Received: from localhost ([127.0.0.1]:36751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIok2-0005Rm-CC for incoming@patchwork.ozlabs.org; Thu, 10 Dec 2009 14:31:58 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NIoVE-0006gz-Ev for qemu-devel@nongnu.org; Thu, 10 Dec 2009 14:16:40 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NIoV8-0006Xk-JR for qemu-devel@nongnu.org; Thu, 10 Dec 2009 14:16:39 -0500 Received: from [199.232.76.173] (port=56466 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIoV8-0006XF-68 for qemu-devel@nongnu.org; Thu, 10 Dec 2009 14:16:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:21563) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NIoV7-0001CM-R5 for qemu-devel@nongnu.org; Thu, 10 Dec 2009 14:16:34 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBAJGWFu010439 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 10 Dec 2009 14:16:33 -0500 Received: from localhost (vpn-9-38.rdu.redhat.com [10.11.9.38]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBAJGVZg028598; Thu, 10 Dec 2009 14:16:32 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 10 Dec 2009 17:15:56 -0200 Message-Id: <1260472570-13973-7-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1260472570-13973-1-git-send-email-lcapitulino@redhat.com> References: <1260472570-13973-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 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)); } }