diff options
-rw-r--r-- | hmp.c | 16 | ||||
-rw-r--r-- | hmp.h | 1 | ||||
-rw-r--r-- | monitor.c | 36 | ||||
-rw-r--r-- | qapi-schema.json | 25 | ||||
-rw-r--r-- | qmp-commands.hx | 6 | ||||
-rw-r--r-- | qmp.c | 13 |
6 files changed, 62 insertions, 35 deletions
@@ -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); +} + @@ -19,5 +19,6 @@ void hmp_info_name(Monitor *mon); void hmp_info_version(Monitor *mon); +void hmp_info_kvm(Monitor *mon); #endif @@ -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", @@ -3188,14 +3162,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 3c0ac4e6ee..641f12da7a 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 9f067ea118..9f9751d1c3 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 ------------ @@ -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; +} + |