]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Change to common source files not directly applicable to open-vm-tools.
authorJohn Wolfe <jwolfe@vmware.com>
Mon, 5 Apr 2021 16:01:41 +0000 (09:01 -0700)
committerJohn Wolfe <jwolfe@vmware.com>
Mon, 5 Apr 2021 16:01:41 +0000 (09:01 -0700)
Add a common function to detect if HyperV is present.

open-vm-tools/lib/include/hostinfo.h
open-vm-tools/lib/misc/hostinfoHV.c

index f098f0217e06398246b471ced6efea76674434db..789a213adf731a722ec695e56ea4db1673bc097b 100644 (file)
@@ -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);
index a3d59f3eb237247a1bd7b19da41db05ece995e45..f3e67045708df659a678ec61ec82c37332e00ab9 100644 (file)
@@ -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;
+}
+
+
 /*
  *----------------------------------------------------------------------
  *