diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hvinfo.adb | 6 | ||||
-rw-r--r-- | src/hypervisor_check.adb | 18 | ||||
-rw-r--r-- | src/hypervisor_check.ads | 4 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/hvinfo.adb b/src/hvinfo.adb index ec4ddcf..8133c3e 100644 --- a/src/hvinfo.adb +++ b/src/hvinfo.adb @@ -120,6 +120,12 @@ begin if SMBIOS_HV_Name /= Null_Unbounded_String then Hypervisor_Name := SMBIOS_HV_Name; Hypervisor_Detected := True; + + -- Special case: QEMU sets different product name for + -- emulated and KVM-accelerated machines + if Get_DMI_Product_Name = KVM then + Hypervisor_Name := US.To_Unbounded_String (KVM); + end if; else if Debug then UIO.Put_Line (IO.Standard_Error, "DMI vendor name is: """ & SMBIOS_Vendor & """"); diff --git a/src/hypervisor_check.adb b/src/hypervisor_check.adb index e598169..23a418f 100644 --- a/src/hypervisor_check.adb +++ b/src/hypervisor_check.adb @@ -188,6 +188,24 @@ package body Hypervisor_Check is return Name; end Get_DMI_Vendor_String; + function Get_DMI_Product_Name return US.Unbounded_String is + Product_Name, Vendor_Name : US.Unbounded_String; + begin + if Config.Linux then + Product_Name := Head_Of_File (Linux_Sys_Product_File); + else + raise OS_Not_Supported; + end if; + + if Contains (Product_Name, KVM_DMI_Pattern) then + Vendor_Name := US.To_Unbounded_String (KVM); + else + Vendor_Name := US.Null_Unbounded_String; + end if; + + return Vendor_Name; + end Get_DMI_Product_Name; + function Get_DMI_Vendor_Name (Vendor_String : US.Unbounded_String) return US.Unbounded_String is Vendor_Name : US.Unbounded_String; begin diff --git a/src/hypervisor_check.ads b/src/hypervisor_check.ads index 3c62f5c..5c561a7 100644 --- a/src/hypervisor_check.ads +++ b/src/hypervisor_check.ads @@ -49,6 +49,8 @@ package Hypervisor_Check is function Get_DMI_Vendor_String return US.Unbounded_String; + function Get_DMI_Product_Name return US.Unbounded_String; + function Command_Succeeds (Command : String) return Boolean; function VirtualBox_PCI_Present return Boolean; @@ -71,6 +73,7 @@ private -- Linux-specific file names etc. Linux_Sys_Vendor_File : constant String := "/sys/class/dmi/id/sys_vendor"; + Linux_Sys_Product_File : constant String := "/sys/class/dmi/id/product_name"; Linux_Sys_HV_Type_File : constant String := "/sys/hypervisor/type"; -- FreeBSD-specific file names, commands etc. @@ -85,6 +88,7 @@ private VirtualBox_DMI_Pattern : constant String := "innotek GmbH"; Parallels_DMI_Pattern : constant String := "Parallels"; QEMU_DMI_Pattern : constant String := "QEMU"; + KVM_DMI_Pattern : constant String := "KVM Virtual Machine"; function CPUID (Arg : Unsigned_32) return CPUID_Registers; |