]> Git Repo - qemu.git/commitdiff
qapi: Convert query-kvm
authorLuiz Capitulino <[email protected]>
Mon, 12 Sep 2011 18:10:53 +0000 (15:10 -0300)
committerLuiz Capitulino <[email protected]>
Tue, 4 Oct 2011 14:02:57 +0000 (11:02 -0300)
Signed-off-by: Anthony Liguori <[email protected]>
Signed-off-by: Luiz Capitulino <[email protected]>
hmp.c
hmp.h
monitor.c
qapi-schema.json
qmp-commands.hx
qmp.c

diff --git a/hmp.c b/hmp.c
index bb6c86f2595643d01521378df3f3840e03e31430..94a7f7448364ac2893fa07866cd2d28de5df3335 100644 (file)
--- 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 2aa75a290478579847af318b988ab2d249af0bef..a93ac1fe2c18989fea3af556e8a6f93b26625646 100644 (file)
--- 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
index 483ea71d1683c158149b90119049629e247178e7..dad4221c49c8b57374319c9f0ad0062c499ac18d 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -2430,31 +2430,6 @@ static void do_info_mtree(Monitor *mon)
     mtree_info((fprintf_function)monitor_printf, mon);
 }
 
-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;
@@ -2955,8 +2930,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",
@@ -3187,14 +3161,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .user_print = do_pci_info_print,
         .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  = "",
index 3c0ac4e6ee4189cf9c5eccbe7a22be8f5aeafc65..641f12da7ad2e050f505b143ba48ab80c76db51f 100644 (file)
 # 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' }
+
index 9f067ea1189add275b3f8198efe8bee09801dcf9..9f9751d1c347de0dc93412fddfdc6bbae64679b8 100644 (file)
@@ -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 f978ea4240866f08a72f481832e3c9f5e41f9e3b..8f7f666bbf9acac29fb984b8efc9205e67604b5d 100644 (file)
--- 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;
+}
+
This page took 0.03918 seconds and 4 git commands to generate.