From patchwork Wed Dec 9 16:27:46 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 40742 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 626B3B7082 for ; Thu, 10 Dec 2009 03:51:57 +1100 (EST) Received: from localhost ([127.0.0.1]:46296 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIPla-0005A3-GP for incoming@patchwork.ozlabs.org; Wed, 09 Dec 2009 11:51:54 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NIPZT-0008NK-N1 for qemu-devel@nongnu.org; Wed, 09 Dec 2009 11:39:23 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NIPZP-0008Kp-PM for qemu-devel@nongnu.org; Wed, 09 Dec 2009 11:39:23 -0500 Received: from [199.232.76.173] (port=48824 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIPZP-0008Ke-DZ for qemu-devel@nongnu.org; Wed, 09 Dec 2009 11:39:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58874) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NIPZO-0007LJ-1K for qemu-devel@nongnu.org; Wed, 09 Dec 2009 11:39:18 -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 nB9GdHFS024275 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 9 Dec 2009 11:39:17 -0500 Received: from localhost (vpn-9-2.rdu.redhat.com [10.11.9.2]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nB9GdFeD007918; Wed, 9 Dec 2009 11:39:16 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 9 Dec 2009 14:27:46 -0200 Message-Id: <1260376078-8694-8-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1260376078-8694-1-git-send-email-lcapitulino@redhat.com> References: <1260376078-8694-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 07/19] monitor: do_info_version(): Use QDict 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 All 'info' commands should use QDict, this commit also kills monitor_print_qobject() as do_info_version() doesn't use it anymore (and no handler will). Signed-off-by: Luiz Capitulino --- monitor.c | 42 ++++++++++++++++++++++-------------------- 1 files changed, 22 insertions(+), 20 deletions(-) diff --git a/monitor.c b/monitor.c index 8729535..775e687 100644 --- a/monitor.c +++ b/monitor.c @@ -257,24 +257,6 @@ static inline int monitor_has_error(const Monitor *mon) return mon->error != NULL; } -static void monitor_print_qobject(Monitor *mon, const QObject *data) -{ - switch (qobject_type(data)) { - case QTYPE_QSTRING: - monitor_printf(mon, "%s",qstring_get_str(qobject_to_qstring(data))); - break; - case QTYPE_QINT: - monitor_printf(mon, "%" PRId64,qint_get_int(qobject_to_qint(data))); - break; - default: - monitor_printf(mon, "ERROR: unsupported type: %d", - qobject_type(data)); - break; - } - - monitor_puts(mon, "\n"); -} - static void monitor_json_emitter(Monitor *mon, const QObject *data) { QString *json; @@ -504,12 +486,32 @@ help: help_cmd(mon, "info"); } +static void do_info_version_print(Monitor *mon, const QObject *data) +{ + QDict *qdict; + + qdict = qobject_to_qdict(data); + + monitor_printf(mon, "%s%s\n", qdict_get_str(qdict, "qemu"), + qdict_get_str(qdict, "package")); +} + /** * do_info_version(): Show QEMU version + * + * Return a QDict with the following information: + * + * - "qemu": QEMU's version + * - "package": package's version + * + * Example: + * + * { "qemu": "0.11.50", "package": "" } */ static void do_info_version(Monitor *mon, QObject **ret_data) { - *ret_data = QOBJECT(qstring_from_str(QEMU_VERSION QEMU_PKGVERSION)); + *ret_data = qobject_from_jsonf("{ 'qemu': %s, 'package': %s }", + QEMU_VERSION, QEMU_PKGVERSION); } static void do_info_name(Monitor *mon) @@ -2200,7 +2202,7 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show the version of QEMU", - .user_print = monitor_print_qobject, + .user_print = do_info_version_print, .mhandler.info_new = do_info_version, }, {