There's no QMP command for querying if hvf is supported, therefore we use sysctl interface that tells if Hypervisor.framwork works/available on the host. Signed-off-by: Roman Bolshakov <r.bolshakov@xxxxxxxxx> --- src/qemu/qemu_capabilities.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 65cf5b5c03..8da0a8476b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -54,6 +54,10 @@ #include <sys/wait.h> #include <stdarg.h> #include <sys/utsname.h> +#ifdef __APPLE__ +#include <sys/types.h> +#include <sys/sysctl.h> +#endif #define VIR_FROM_THIS VIR_FROM_QEMU @@ -2577,6 +2581,27 @@ virQEMUCapsProbeQMPKVMState(virQEMUCapsPtr qemuCaps, return 0; } +static int +virQEMUCapsProbeHVF(virQEMUCapsPtr qemuCaps, + qemuMonitorPtr mon) +{ + (void)mon; + int hv_support = 0; +#ifdef __APPLE__ + size_t len = sizeof(hv_support); + if (sysctlbyname("kern.hv_support", &hv_support, &len, NULL, 0)) + hv_support = 0; +#endif + + if (qemuCaps->version >= 2012000 && + ARCH_IS_X86(qemuCaps->arch) && + hv_support) { + virQEMUCapsSet(qemuCaps, QEMU_CAPS_HVF); + } + + return 0; +} + struct virQEMUCapsCommandLineProps { const char *option; const char *param; @@ -4123,6 +4148,9 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, if (virQEMUCapsProbeQMPKVMState(qemuCaps, mon) < 0) goto cleanup; + if (virQEMUCapsProbeHVF(qemuCaps, mon) < 0) + goto cleanup; + if (virQEMUCapsProbeQMPEvents(qemuCaps, mon) < 0) goto cleanup; if (virQEMUCapsProbeQMPDevices(qemuCaps, mon) < 0) -- 2.17.1 (Apple Git-112) -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list