On Thu, Aug 07, 2025 at 07:22:21PM +0000, Wei Liu wrote:
> On Thu, Aug 07, 2025 at 04:39:51PM +0200, Magnus Kulke wrote:
> > 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);
> 
> I don't think this is the right way to check if MSHV is _enabled_. The
> device node being around doesn't necessarily mean that QEMU is using it.
> 
> You can refer to kvm_enabled() to see how it is implemented.
> 
> Some functions that are of interest:
>    do_configure_accelerator
>    accel_init_machine

This is likely as simple as squashing in the following diff.

diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 024ddb8d2d7c..1b520599972a 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -39,7 +39,7 @@ MshvInfo *qmp_query_mshv(Error **errp)
     struct stat st;

     info->present = accel_find("mshv");
-    info->enabled = (stat("/dev/mshv", &st) == 0);
+    info->enabled = mshv_enabled();
     return info;
 }

Reply via email to