From patchwork Wed Dec 9 16:27:49 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 40745 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 F0DD2B6EF6 for ; Thu, 10 Dec 2009 03:57:54 +1100 (EST) Received: from localhost ([127.0.0.1]:38901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIPrK-00005N-Su for incoming@patchwork.ozlabs.org; Wed, 09 Dec 2009 11:57:50 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NIPZb-0008SC-Ap for qemu-devel@nongnu.org; Wed, 09 Dec 2009 11:39:31 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NIPZW-0008Ol-9a for qemu-devel@nongnu.org; Wed, 09 Dec 2009 11:39:30 -0500 Received: from [199.232.76.173] (port=48828 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIPZW-0008Od-6p for qemu-devel@nongnu.org; Wed, 09 Dec 2009 11:39:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:21302) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NIPZV-0007MT-QF for qemu-devel@nongnu.org; Wed, 09 Dec 2009 11:39:26 -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 nB9GdODI010179 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 9 Dec 2009 11:39:24 -0500 Received: from localhost (vpn-9-2.rdu.redhat.com [10.11.9.2]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nB9GdNjA013502; Wed, 9 Dec 2009 11:39:24 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 9 Dec 2009 14:27:49 -0200 Message-Id: <1260376078-8694-11-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.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 10/19] 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 | 29 +++++++++++++++++++++++++---- 1 files changed, 25 insertions(+), 4 deletions(-) diff --git a/monitor.c b/monitor.c index 47f794d..3d33bd8 100644 --- a/monitor.c +++ b/monitor.c @@ -514,10 +514,30 @@ 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); + const char *str; + + str = qdict_get_str(qobject_to_qdict(data), "name"); + if (strlen(str) > 0) { + monitor_printf(mon, "%s\n", str); + } +} + +/** + * do_info_name(): Show VM name + * + * Return a QDict with the following information: + * + * - "name": VM's name. If the VM has no name, the string will be empty + * + * Example: + * + * { "name": "qemu-name" } + */ +static void do_info_name(Monitor *mon, QObject **ret_data) +{ + *ret_data = qobject_from_jsonf("{'name': %s}", qemu_name ? qemu_name : ""); } /** @@ -2449,7 +2469,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",