From patchwork Thu Dec 10 14:43:25 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 40816 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 A279DB6F0A for ; Fri, 11 Dec 2009 02:03:29 +1100 (EST) Received: from localhost ([127.0.0.1]:55879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIkYA-0001Ig-Ux for incoming@patchwork.ozlabs.org; Thu, 10 Dec 2009 10:03:26 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NIkFY-0001QE-Jk for qemu-devel@nongnu.org; Thu, 10 Dec 2009 09:44:12 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NIkFU-0001Ns-To for qemu-devel@nongnu.org; Thu, 10 Dec 2009 09:44:12 -0500 Received: from [199.232.76.173] (port=45376 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIkFU-0001No-G8 for qemu-devel@nongnu.org; Thu, 10 Dec 2009 09:44:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33650) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NIkFT-0004Do-BL for qemu-devel@nongnu.org; Thu, 10 Dec 2009 09:44:08 -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 nBAEi5K6023172 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 10 Dec 2009 09:44:06 -0500 Received: from localhost (vpn-11-77.rdu.redhat.com [10.11.11.77]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBAEi4NE001489; Thu, 10 Dec 2009 09:44:05 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 10 Dec 2009 12:43:25 -0200 Message-Id: <1260456215-31022-11-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.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 10/20] monitor: Convert do_info_kvm() 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 | 41 +++++++++++++++++++++++++++++++++-------- 1 files changed, 33 insertions(+), 8 deletions(-) diff --git a/monitor.c b/monitor.c index 01d5827..3f26c5a 100644 --- a/monitor.c +++ b/monitor.c @@ -1806,16 +1806,40 @@ static void tlb_info(Monitor *mon) #endif -static void do_info_kvm(Monitor *mon) +static void do_info_kvm_print(Monitor *mon, const QObject *data) { -#ifdef CONFIG_KVM + QDict *qdict; + + qdict = qobject_to_qdict(data); + monitor_printf(mon, "kvm support: "); - if (kvm_enabled()) - monitor_printf(mon, "enabled\n"); - else - monitor_printf(mon, "disabled\n"); + if (qdict_get_bool(qdict, "present")) { + monitor_printf(mon, "%s\n", qdict_get_bool(qdict, "enabled") ? + "enabled" : "disabled"); + } else { + monitor_printf(mon, "not compiled\n"); + } +} + +/** + * do_info_kvm(): Show KVM information + * + * Return a QDict with the following information: + * + * - "enabled": true if KVM support is enabled, false otherwise + * - "present": true if QEMU has KVM support, false otherwise + * + * Example: + * + * { "enabled": true, "present": true } + */ +static void do_info_kvm(Monitor *mon, QObject **ret_data) +{ +#ifdef CONFIG_KVM + *ret_data = qobject_from_jsonf("{ 'enabled': %i, 'present': true }", + kvm_enabled()); #else - monitor_printf(mon, "kvm support: not compiled\n"); + *ret_data = qobject_from_jsonf("{ 'enabled': false, 'present': false }"); #endif } @@ -2369,7 +2393,8 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show KVM information", - .mhandler.info = do_info_kvm, + .user_print = do_info_kvm_print, + .mhandler.info_new = do_info_kvm, }, { .name = "numa",