From patchwork Thu Dec 10 14:43:26 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 40817 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 E647DB6F12 for ; Fri, 11 Dec 2009 02:05:19 +1100 (EST) Received: from localhost ([127.0.0.1]:56861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIkZx-0003kJ-7O for incoming@patchwork.ozlabs.org; Thu, 10 Dec 2009 10:05:17 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NIkFa-0001RW-NV for qemu-devel@nongnu.org; Thu, 10 Dec 2009 09:44:14 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NIkFW-0001Ou-7v for qemu-devel@nongnu.org; Thu, 10 Dec 2009 09:44:14 -0500 Received: from [199.232.76.173] (port=45378 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIkFV-0001Og-Nx for qemu-devel@nongnu.org; Thu, 10 Dec 2009 09:44:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:31130) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NIkFV-0004E6-NK for qemu-devel@nongnu.org; Thu, 10 Dec 2009 09:44:09 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBAEi8tp010173 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 10 Dec 2009 09:44:08 -0500 Received: from localhost (vpn-11-77.rdu.redhat.com [10.11.11.77]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBAEi6rA010414; Thu, 10 Dec 2009 09:44:07 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 10 Dec 2009 12:43:26 -0200 Message-Id: <1260456215-31022-12-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.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 11/20] monitor: Convert do_info_name() to QObject 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 Signed-off-by: Luiz Capitulino --- monitor.c | 32 ++++++++++++++++++++++++++++---- 1 files changed, 28 insertions(+), 4 deletions(-) diff --git a/monitor.c b/monitor.c index 3f26c5a..a2433e9 100644 --- a/monitor.c +++ b/monitor.c @@ -514,10 +514,33 @@ static void do_info_version(Monitor *mon, QObject **ret_data) QEMU_VERSION, QEMU_PKGVERSION); } -static void do_info_name(Monitor *mon) +static void do_info_name_print(Monitor *mon, const QObject *data) { - if (qemu_name) - monitor_printf(mon, "%s\n", qemu_name); + QDict *qdict; + + qdict = qobject_to_qdict(data); + if (qdict_size(qdict) == 0) { + return; + } + + monitor_printf(mon, "%s\n", qdict_get_str(qdict, "name")); +} + +/** + * do_info_name(): Show VM name + * + * Return a QDict with the following information: + * + * - "name": VM's name (optional) + * + * Example: + * + * { "name": "qemu-name" } + */ +static void do_info_name(Monitor *mon, QObject **ret_data) +{ + *ret_data = qemu_name ? qobject_from_jsonf("{'name': %s }", qemu_name) : + qobject_from_jsonf("{}"); } static QObject *get_cmd_dict(const char *name) @@ -2472,7 +2495,8 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show the current VM name", - .mhandler.info = do_info_name, + .user_print = do_info_name_print, + .mhandler.info_new = do_info_name, }, { .name = "uuid",