mirror of
https://github.com/qemu/qemu.git
synced 2026-02-04 05:35:39 +00:00
monitor: generalize query-mshv/"info mshv" to query-accelerators/"info accelerators"
The recently-introduced query-mshv command is a duplicate of query-kvm,
and neither provides a full view of which accelerators are supported
by a particular binary of QEMU and which is in use.
KVM was the first accelerator added to QEMU, predating QOM and TYPE_ACCEL,
so it got a pass. But now, instead of adding a badly designed copy, solve
the problem completely for all accelerators with a command that provides
the whole picture:
>> {"execute": "query-accelerators"}
<< {"return": {"enabled": "tcg", "present": ["kvm", "mshv", "qtest", "tcg", "xen"]}}
Cc: Praveen K Paladugu <prapal@microsoft.com>
Cc: Magnus Kulke <magnuskulke@linux.microsoft.com>
Suggested-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
@@ -308,16 +308,21 @@ SRST
|
||||
ERST
|
||||
|
||||
{
|
||||
.name = "mshv",
|
||||
.name = "accelerators",
|
||||
.args_type = "",
|
||||
.params = "",
|
||||
.help = "show MSHV information",
|
||||
.cmd = hmp_info_mshv,
|
||||
.help = "show present and enabled information",
|
||||
.cmd = hmp_info_accelerators,
|
||||
},
|
||||
|
||||
SRST
|
||||
``info mshv``
|
||||
Show MSHV information.
|
||||
``info accelerators``
|
||||
Show which accelerators are compiled into a QEMU binary, and what accelerator
|
||||
is in use. For example::
|
||||
|
||||
kvm qtest [tcg]
|
||||
|
||||
indicates that TCG in use, and that KVM and qtest are also available.
|
||||
ERST
|
||||
|
||||
{
|
||||
|
||||
@@ -163,19 +163,22 @@ void hmp_info_kvm(Monitor *mon, const QDict *qdict)
|
||||
qapi_free_KvmInfo(info);
|
||||
}
|
||||
|
||||
void hmp_info_mshv(Monitor *mon, const QDict *qdict)
|
||||
void hmp_info_accelerators(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
MshvInfo *info;
|
||||
AcceleratorInfo *info;
|
||||
AcceleratorList *accel;
|
||||
|
||||
info = qmp_query_mshv(NULL);
|
||||
monitor_printf(mon, "mshv support: ");
|
||||
if (info->present) {
|
||||
monitor_printf(mon, "%s\n", info->enabled ? "enabled" : "disabled");
|
||||
} else {
|
||||
monitor_printf(mon, "not compiled\n");
|
||||
info = qmp_query_accelerators(NULL);
|
||||
for (accel = info->present; accel; accel = accel->next) {
|
||||
char trail = accel->next ? ' ' : '\n';
|
||||
if (info->enabled == accel->value) {
|
||||
monitor_printf(mon, "[%s]%c", Accelerator_str(accel->value), trail);
|
||||
} else {
|
||||
monitor_printf(mon, "%s%c", Accelerator_str(accel->value), trail);
|
||||
}
|
||||
}
|
||||
|
||||
qapi_free_MshvInfo(info);
|
||||
qapi_free_AcceleratorInfo(info);
|
||||
}
|
||||
|
||||
void hmp_info_uuid(Monitor *mon, const QDict *qdict)
|
||||
|
||||
@@ -31,15 +31,25 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
/*
|
||||
* QMP query for MSHV
|
||||
* QMP query for enabled and present accelerators
|
||||
*/
|
||||
MshvInfo *qmp_query_mshv(Error **errp)
|
||||
AcceleratorInfo *qmp_query_accelerators(Error **errp)
|
||||
{
|
||||
MshvInfo *info = g_malloc0(sizeof(*info));
|
||||
AcceleratorInfo *info = g_malloc0(sizeof(*info));
|
||||
AccelClass *current_class = ACCEL_GET_CLASS(current_accel());
|
||||
int i;
|
||||
|
||||
info->enabled = mshv_enabled();
|
||||
info->present = accel_find("mshv");
|
||||
for (i = ACCELERATOR__MAX; i-- > 0; ) {
|
||||
const char *s = Accelerator_str(i);
|
||||
AccelClass *this_class = accel_find(s);
|
||||
|
||||
if (this_class) {
|
||||
QAPI_LIST_PREPEND(info->present, i);
|
||||
if (this_class == current_class) {
|
||||
info->enabled = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ strList *hmp_split_at_comma(const char *str);
|
||||
void hmp_info_name(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_version(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_kvm(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_mshv(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_accelerators(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_status(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_uuid(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_chardev(Monitor *mon, const QDict *qdict);
|
||||
|
||||
@@ -56,30 +56,55 @@
|
||||
'features': [ 'unstable' ] }
|
||||
|
||||
##
|
||||
# @MshvInfo:
|
||||
# @Accelerator:
|
||||
#
|
||||
# Information about support for MSHV acceleration
|
||||
#
|
||||
# @enabled: true if MSHV acceleration is active
|
||||
# @hvf: Apple Hypervisor.framework
|
||||
#
|
||||
# @present: true if MSHV acceleration is built into this executable
|
||||
# @kvm: KVM
|
||||
#
|
||||
# @mshv: Hyper-V
|
||||
#
|
||||
# @nvmm: NetBSD NVMM
|
||||
#
|
||||
# @qtest: QTest (dummy accelerator)
|
||||
#
|
||||
# @tcg: TCG (dynamic translation)
|
||||
#
|
||||
# @whpx: Windows Hypervisor Platform
|
||||
#
|
||||
# @xen: Xen
|
||||
#
|
||||
# Since: 10.2.0
|
||||
##
|
||||
{ 'struct': 'MshvInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
|
||||
{ 'enum': 'Accelerator', 'data': ['hvf', 'kvm', 'mshv', 'nvmm', 'qtest', 'tcg', 'whpx', 'xen'] }
|
||||
|
||||
##
|
||||
# @query-mshv:
|
||||
# @AcceleratorInfo:
|
||||
#
|
||||
# Return information about MSHV acceleration
|
||||
# Information about support for various accelerators
|
||||
#
|
||||
# Returns: @MshvInfo
|
||||
# @enabled: the accelerator that is in use
|
||||
#
|
||||
# Since: 10.0.92
|
||||
# @present: the list of accelerators that are built into this executable
|
||||
#
|
||||
# Since: 10.2.0
|
||||
##
|
||||
{ 'struct': 'AcceleratorInfo', 'data': {'enabled': 'Accelerator', 'present': ['Accelerator']} }
|
||||
|
||||
##
|
||||
# @query-accelerators:
|
||||
#
|
||||
# Return information about accelerators
|
||||
#
|
||||
# Returns: @AcceleratorInfo
|
||||
#
|
||||
# Since: 10.2.0
|
||||
#
|
||||
# .. qmp-example::
|
||||
#
|
||||
# -> { "execute": "query-mshv" }
|
||||
# <- { "return": { "enabled": true, "present": true } }
|
||||
# -> { "execute": "query-accelerators" }
|
||||
# <- { "return": { "enabled": "mshv", "present": ["kvm", "mshv", "qtest", "tcg"] } }
|
||||
##
|
||||
{ 'command': 'query-mshv', 'returns': 'MshvInfo' }
|
||||
{ 'command': 'query-accelerators', 'returns': 'AcceleratorInfo' }
|
||||
|
||||
Reference in New Issue
Block a user