On Fri, Aug 29, 2025 at 03:28:34PM -0500, Praveen K Paladugu wrote:
> Probe mshv capabilities from qemu with QMP commands. Limit probing only
> to x86_64 architecture with newer versions of QEMU.
> 
> Signed-off-by: Praveen K Paladugu <[email protected]>
> ---
>  src/qemu/qemu_capabilities.c | 21 +++++++++++++++++++++
>  src/qemu/qemu_monitor.c      | 12 ++++++++++++
>  src/qemu/qemu_monitor.h      | 12 +++++++++---
>  src/qemu/qemu_monitor_json.c | 32 ++++++++++++++++++++++++++------
>  src/qemu/qemu_monitor_json.h | 13 +++++++++----
>  5 files changed, 77 insertions(+), 13 deletions(-)
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 1e069eb0e5..cc7774a58a 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -3488,6 +3488,22 @@ virQEMUCapsProbeQMPKVMState(virQEMUCaps *qemuCaps,
>      return 0;
>  }
>  
> +static int
> +virQEMUCapsProbeQMPMSHVState(virQEMUCaps *qemuCaps,
> +                            qemuMonitor *mon)
> +{
> +    bool enabled = false;
> +    bool present = false;
> +
> +    if (qemuMonitorGetMSHVState(mon, &enabled, &present) < 0)
> +        return -1;
> +
> +    if (present && enabled)
> +        virQEMUCapsSet(qemuCaps, QEMU_CAPS_MSHV);
> +
> +    return 0;
> +}
> +
>  #ifdef __APPLE__
>  bool
>  virQEMUCapsProbeHVF(virQEMUCaps *qemuCaps)
> @@ -5795,6 +5811,11 @@ virQEMUCapsInitQMPMonitor(virQEMUCaps *qemuCaps,
>      if (virQEMUCapsProbeQMPKVMState(qemuCaps, mon) < 0)
>          return -1;
>  
> +    if (qemuCaps->arch == VIR_ARCH_X86_64 && qemuCaps->version >= 10000092) {
> +        if (virQEMUCapsProbeQMPMSHVState(qemuCaps, mon) < 0)
> +            return -1;
> +    }

This change causes the test suite to break at this point in the series.

  TEST: qemucapabilitiestest
        ........................................
  wrong expected command in 
/var/home/berrange/src/virt/libvirt/tests/qemucapabilitiesdata/caps_10.1.0_x86_64.replies:24767:
 : {"execute":"query-mshv","id":"libvirt-6"} expected 
{"execute":"qom-list-types","id":"libvirt-6"}

In order to ensure that it is possible to use 'git bisect' without
spurious failures, we aim to have tests pass at every patch in a
series.

More importantly, we generally aim to avoid having version number
checks and instead rely on detected features.

If you introduce a new QEMU_CAPS_QUERY_MSHV capability flag, you
can update the 'virQEMUCapsCommands' array to match 'query-mshv'.

Then at this point in the code you can drop the arch check and
the version check, and instead check QEMU_CAPS_QUERY_MSHV as
a witness for being able to call virQEMUCapsProbeQMPMSHVState.

Possibly still need some updates to the qemucapabilitiesdata
files after doing that in this commit, but not 100% sure.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Reply via email to