summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2009-12-10 17:16:00 -0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-12-12 08:17:31 -0600
commit94f539bdac57daea5f5d853cfee86bd683cf81cf (patch)
tree4898b59e112ed47a7b8ea4de93840b01e5312d91 /monitor.c
parentmonitor: Convert do_info_status() to QObject (diff)
downloadqemu-kvm-94f539bdac57daea5f5d853cfee86bd683cf81cf.tar.gz
qemu-kvm-94f539bdac57daea5f5d853cfee86bd683cf81cf.tar.bz2
qemu-kvm-94f539bdac57daea5f5d853cfee86bd683cf81cf.zip
monitor: Convert do_info_kvm() to QObject
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> (cherry picked from commit 2af5ba712b3e03cf644320f7386bf1dfd2c2b6a8)
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/monitor.c b/monitor.c
index 3d37548d6..18c461215 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",