From: Praveen K Paladugu <pra...@microsoft.com> Allow to query mshv capabilities via query-mshv QMP command.
Signed-off-by: Praveen K Paladugu <pra...@linux.microsoft.com> Signed-off-by: Magnus Kulke <magnusku...@linux.microsoft.com> --- hw/core/machine-qmp-cmds.c | 14 ++++++++++++++ qapi/accelerator.json | 29 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index 6aca1a626e..024ddb8d2d 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -28,6 +28,20 @@ #include "system/runstate.h" #include "system/system.h" #include "hw/s390x/storage-keys.h" +#include <sys/stat.h> + +/* + * QMP query for MSHV + */ +MshvInfo *qmp_query_mshv(Error **errp) +{ + MshvInfo *info = g_malloc0(sizeof(*info)); + struct stat st; + + info->present = accel_find("mshv"); + info->enabled = (stat("/dev/mshv", &st) == 0); + return info; +} /* * fast means: we NEVER interrupt vCPU threads to retrieve diff --git a/qapi/accelerator.json b/qapi/accelerator.json index fb28c8d920..c2bfbc507f 100644 --- a/qapi/accelerator.json +++ b/qapi/accelerator.json @@ -54,3 +54,32 @@ { 'command': 'x-accel-stats', 'returns': 'HumanReadableText', 'features': [ 'unstable' ] } + +## +# @MshvInfo: +# +# Information about support for MSHV acceleration +# +# @enabled: true if MSHV acceleration is active +# +# @present: true if MSHV acceleration is built into this executable +# +# Since: 10.0.92 +## +{ 'struct': 'MshvInfo', 'data': {'enabled': 'bool', 'present': 'bool'} } + +## +# @query-mshv: +# +# Return information about MSHV acceleration +# +# Returns: @MshvInfo +# +# Since: 10.0.92 +# +# .. qmp-example:: +# +# -> { "execute": "query-mshv" } +# <- { "return": { "enabled": true, "present": true } } +## +{ 'command': 'query-mshv', 'returns': 'MshvInfo' } -- 2.34.1