From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Luiz Capitulino 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> Subject: [Qemu-devel] [PATCH 06/20] monitor: Fix do_info_commands() output List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com 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)); } } -- 1.6.6.rc1.39.g9a42