From 29a9fc9af63a4c897ac718894f8f01bb50a38104 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Mon, 6 Apr 2015 16:40:03 +0600 Subject: Add VirtualBox PCI detection on FreeBSD. --- src/hvinfo.adb | 2 ++ src/hypervisor_check.adb | 18 ++++++++++++++++++ src/hypervisor_check.ads | 2 ++ 3 files changed, 22 insertions(+) (limited to 'src') diff --git a/src/hvinfo.adb b/src/hvinfo.adb index e9729a5..e15c75d 100644 --- a/src/hvinfo.adb +++ b/src/hvinfo.adb @@ -73,6 +73,8 @@ begin IO.Put_Line(IO.Standard_Error, "No hypervisor detected"); CL.Set_Exit_Status (1); end if; + elsif VirtualBox_PCI_Present then + IO.Put_Line (VirtualBox); end if; end if; diff --git a/src/hypervisor_check.adb b/src/hypervisor_check.adb index 30bccf3..df8391b 100644 --- a/src/hypervisor_check.adb +++ b/src/hypervisor_check.adb @@ -191,4 +191,22 @@ package body Hypervisor_Check is end if; end Known_DMI_HV_Vendor; + function VirtualBox_PCI_Present return Boolean is + begin + if Config.FreeBSD then + if Command_Succeeds ("/sbin/sysctl dev.vgapci | grep vendor=0x80ee") then + return True; + else + return False; + end if; + elsif Config.Linux then + -- Can be done, but on Linux VirtualBox is covered by DMI checks, + -- so I cut the corners here + -- XXX: maybe it's relevant on some UEFI machines + return False; + else + return False; + end if; + end; + end Hypervisor_Check; diff --git a/src/hypervisor_check.ads b/src/hypervisor_check.ads index f4b1eef..3941f8f 100644 --- a/src/hypervisor_check.ads +++ b/src/hypervisor_check.ads @@ -30,6 +30,8 @@ package Hypervisor_Check is function Command_Succeeds (Command : Interfaces.C.Char_Array) return Boolean; + function VirtualBox_PCI_Present return Boolean; + -- Vendor names for human consumption VMWare : constant String := "VMWare"; Xen_HVM : constant String := "Xen HVM"; -- cgit v1.2.3