From: John Wolfe Date: Mon, 5 Apr 2021 16:01:41 +0000 (-0700) Subject: Change to common source files not directly applicable to open-vm-tools. X-Git-Tag: stable-11.3.0~87 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a98b8f5d3669812e1524cd692e1dd897e5f0ba9;p=thirdparty%2Fopen-vm-tools.git Change to common source files not directly applicable to open-vm-tools. Add a common function to detect if HyperV is present. --- diff --git a/open-vm-tools/lib/include/hostinfo.h b/open-vm-tools/lib/include/hostinfo.h index f098f0217..789a213ad 100644 --- a/open-vm-tools/lib/include/hostinfo.h +++ b/open-vm-tools/lib/include/hostinfo.h @@ -160,6 +160,7 @@ Bool Hostinfo_NestedHVReplaySupported(void); Bool Hostinfo_TouchBackDoor(void); Bool Hostinfo_TouchVirtualPC(void); Bool Hostinfo_TouchXen(void); +Bool Hostinfo_HyperV(void); char *Hostinfo_HypervisorCPUIDSig(void); void Hostinfo_LogHypervisorCPUID(void); char *Hostinfo_HypervisorInterfaceSig(void); diff --git a/open-vm-tools/lib/misc/hostinfoHV.c b/open-vm-tools/lib/misc/hostinfoHV.c index a3d59f3eb..f3e670457 100644 --- a/open-vm-tools/lib/misc/hostinfoHV.c +++ b/open-vm-tools/lib/misc/hostinfoHV.c @@ -388,6 +388,40 @@ Hostinfo_TouchXen(void) } +/* + *---------------------------------------------------------------------- + * + * Hostinfo_HyperV -- + * + * Check for HyperV. + * + * Results: + * TRUE if we are running in HyperV. + * FALSE otherwise. + * + *---------------------------------------------------------------------- + */ + +Bool +Hostinfo_HyperV(void) +{ + Bool hyperVAvailable = FALSE; +#if defined(__i386__) || defined(__x86_64__) + char *hypervisorSig = Hostinfo_HypervisorCPUIDSig(); + + if (hypervisorSig) { + if (!memcmp(CPUID_HYPERV_HYPERVISOR_VENDOR_STRING, hypervisorSig, + sizeof CPUID_HYPERV_HYPERVISOR_VENDOR_STRING)) { + hyperVAvailable = TRUE; + } + free(hypervisorSig); + } +#endif + + return hyperVAvailable; +} + + /* *---------------------------------------------------------------------- *