[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 15/26] qapi: Convert query-kvm
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 15/26] qapi: Convert query-kvm |
Date: |
Fri, 30 Sep 2011 17:34:40 -0300 |
Signed-off-by: Anthony Liguori <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
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;
+}
+
--
1.7.7.rc0.72.g4b5ea
- [Qemu-devel] [PATCH 11/26] qapi: Don't use c_var() on enum strings, (continued)
- [Qemu-devel] [PATCH 11/26] qapi: Don't use c_var() on enum strings, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 10/26] qapi: modify visitor code generation for list iteration, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 02/26] qerror: add qerror_report_err(), Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 08/26] qapi: add test cases for generated free functions, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 12/26] qapi: Automatically generate a _MAX value for enums, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 13/26] qapi: convert query-name, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 01/26] error: let error_is_type take a NULL error, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 14/26] qapi: Convert query-version, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 17/26] RunState: Drop the RSTATE_NO_STATE value, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 16/26] vl: Change qemu_vmstop_requested() to return a bool, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 15/26] qapi: Convert query-kvm,
Luiz Capitulino <=
- [Qemu-devel] [PATCH 03/26] qapi: add code generation support for middle mode, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 25/26] qapi: Convert system_reset, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 20/26] qapi: Convert query-uuid, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 18/26] RunState: Rename enum values as generated by the QAPI, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 21/26] qapi: Convert query-chardev, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 19/26] qapi: Convert query-status, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 22/26] qapi: Convert query-commands, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 24/26] qapi: Convert stop, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 26/26] qapi: Convert system_powerdown, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 23/26] qapi: Convert quit, Luiz Capitulino, 2011/09/30