On Sat, Oct 20, 2018 at 05:19:48PM +0300, Roman Bolshakov wrote:
> 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.bolsha...@yadro.com>
> ---
>  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__

I think i'd prefer the ifdef to surround the entire
method, and then provide a separate impl that just
does 'return 0' for non-apple platforms, since none
of the code here is useful for non-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;
> +}

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 :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to