From patchwork Wed Sep 28 14:44:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 116818 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3C0011007D1 for ; Thu, 29 Sep 2011 01:15:46 +1000 (EST) Received: from localhost ([::1]:53067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8vPT-0006dQ-Ga for incoming@patchwork.ozlabs.org; Wed, 28 Sep 2011 10:46:55 -0400 Received: from eggs.gnu.org ([140.186.70.92]:46897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8vO2-00031i-K1 for qemu-devel@nongnu.org; Wed, 28 Sep 2011 10:45:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8vNq-0004xg-2x for qemu-devel@nongnu.org; Wed, 28 Sep 2011 10:45:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1203) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8vNp-0004xY-Lh for qemu-devel@nongnu.org; Wed, 28 Sep 2011 10:45:14 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8SEjB6l003215 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Sep 2011 10:45:11 -0400 Received: from localhost (ovpn-113-147.phx2.redhat.com [10.3.113.147]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p8SEjAPO007834; Wed, 28 Sep 2011 10:45:11 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 28 Sep 2011 11:44:37 -0300 Message-Id: <1317221085-5825-14-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1317221085-5825-1-git-send-email-lcapitulino@redhat.com> References: <1317221085-5825-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, aliguori@us.ibm.com, mdroth@linux.vnet.ibm.com, armbru@redhat.com Subject: [Qemu-devel] [PATCH 13/21] qapi: Convert query-kvm X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The original conversion was done by Anthony Liguori. This commit is just a rebase. Signed-off-by: Luiz Capitulino --- hmp.c | 16 ++++++++++++++++ hmp.h | 1 + monitor.c | 36 +----------------------------------- qapi-schema.json | 25 +++++++++++++++++++++++++ qmp-commands.hx | 6 ++++++ qmp.c | 13 +++++++++++++ 6 files changed, 62 insertions(+), 35 deletions(-) diff --git a/hmp.c b/hmp.c index bb6c86f..94a7f74 100644 --- a/hmp.c +++ b/hmp.c @@ -37,3 +37,19 @@ void hmp_info_version(Monitor *mon) qapi_free_VersionInfo(info); } + +void hmp_info_kvm(Monitor *mon) +{ + KvmInfo *info; + + info = qmp_query_kvm(NULL); + monitor_printf(mon, "kvm support: "); + if (info->present) { + monitor_printf(mon, "%s\n", info->enabled ? "enabled" : "disabled"); + } else { + monitor_printf(mon, "not compiled\n"); + } + + qapi_free_KvmInfo(info); +} + diff --git a/hmp.h b/hmp.h index 2aa75a2..a93ac1f 100644 --- a/hmp.h +++ b/hmp.h @@ -19,5 +19,6 @@ void hmp_info_name(Monitor *mon); void hmp_info_version(Monitor *mon); +void hmp_info_kvm(Monitor *mon); #endif diff --git a/monitor.c b/monitor.c index 9edc38c..edb56b9 100644 --- a/monitor.c +++ b/monitor.c @@ -2424,31 +2424,6 @@ static void tlb_info(Monitor *mon) } #endif -static void do_info_kvm_print(Monitor *mon, const QObject *data) -{ - QDict *qdict; - - qdict = qobject_to_qdict(data); - - monitor_printf(mon, "kvm support: "); - 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"); - } -} - -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 - *ret_data = qobject_from_jsonf("{ 'enabled': false, 'present': false }"); -#endif -} - static void do_info_numa(Monitor *mon) { int i; @@ -2942,8 +2917,7 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show KVM information", - .user_print = do_info_kvm_print, - .mhandler.info_new = do_info_kvm, + .mhandler.info = hmp_info_kvm, }, { .name = "numa", @@ -3175,14 +3149,6 @@ static const mon_cmd_t qmp_query_cmds[] = { .mhandler.info_new = do_pci_info, }, { - .name = "kvm", - .args_type = "", - .params = "", - .help = "show KVM information", - .user_print = do_info_kvm_print, - .mhandler.info_new = do_info_kvm, - }, - { .name = "status", .args_type = "", .params = "", diff --git a/qapi-schema.json b/qapi-schema.json index 3c0ac4e..641f12d 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -60,3 +60,28 @@ # Since: 0.14.0 ## { 'command': 'query-version', 'returns': 'VersionInfo' } + +## +# @KvmInfo: +# +# Information about support for KVM acceleration +# +# @enabled: true if KVM acceleration is active +# +# @present: true if KVM acceleration is built into this executable +# +# Since: 0.14.0 +## +{ 'type': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} } + +## +# @query-kvm: +# +# Returns information about KVM acceleration +# +# Returns: @KvmInfo +# +# Since: 0.14.0 +## +{ 'command': 'query-kvm', 'returns': 'KvmInfo' } + diff --git a/qmp-commands.hx b/qmp-commands.hx index 9f067ea..9f9751d 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1570,6 +1570,12 @@ Example: EQMP + { + .name = "query-kvm", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_kvm, + }, + SQMP query-status ------------ diff --git a/qmp.c b/qmp.c index f978ea4..8f7f666 100644 --- a/qmp.c +++ b/qmp.c @@ -14,6 +14,8 @@ #include "qemu-common.h" #include "sysemu.h" #include "qmp-commands.h" +#include "kvm.h" +#include "arch_init.h" NameInfo *qmp_query_name(Error **errp) { @@ -42,3 +44,14 @@ VersionInfo *qmp_query_version(Error **err) return info; } + +KvmInfo *qmp_query_kvm(Error **errp) +{ + KvmInfo *info = g_malloc0(sizeof(*info)); + + info->enabled = kvm_enabled(); + info->present = kvm_available(); + + return info; +} +