Skip to content

Commit c19d866

Browse files
committed
Merge pull request docker-archive-public#3248 from theodthompson/patch-hyperv-check
adding hypervisor check to virtualbox pre-create check
2 parents c120a92 + b419c5d commit c19d866

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

drivers/virtualbox/virtualbox.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const (
3636
var (
3737
ErrUnableToGenerateRandomIP = errors.New("unable to generate random IP")
3838
ErrMustEnableVTX = errors.New("This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory")
39-
ErrNotCompatibleWithHyperV = errors.New("Hyper-V is installed. VirtualBox won't boot a 64bits VM when Hyper-V is activated. If it's installed but deactivated, you can use --virtualbox-no-vtx-check to try anyways")
39+
ErrNotCompatibleWithHyperV = errors.New("This computer is running Hyper-V. VirtualBox won't boot a 64bits VM when Hyper-V is activated. Either use Hyper-V as a driver, or disable the Hyper-V hypervisor. (To skip this check, use --virtualbox-no-vtx-check)")
4040
ErrNetworkAddrCidr = errors.New("host-only cidr must be specified with a host address, not a network address")
4141
ErrNetworkAddrCollision = errors.New("host-only cidr conflicts with the network address of a host interface")
4242
)

drivers/virtualbox/virtualbox_windows.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,25 @@ func getShareDriveAndName() (string, string) {
9595
}
9696

9797
func isHyperVInstalled() bool {
98+
// check if hyper-v is installed
9899
_, err := exec.LookPath("vmms.exe")
99-
return err == nil
100+
if err != nil {
101+
errmsg := "Hyper-V is not installed."
102+
log.Debugf(errmsg, err)
103+
return false
104+
}
105+
106+
// check to see if a hypervisor is present. if hyper-v is installed and enabled,
107+
// display an error explaining the incompatibility between virtualbox and hyper-v.
108+
output, err := cmdOutput("wmic", "computersystem", "get", "hypervisorpresent")
109+
110+
if err != nil {
111+
errmsg := "Could not check to see if Hyper-V is running."
112+
log.Debugf(errmsg, err)
113+
return false
114+
}
115+
116+
enabled := strings.Contains(output, "TRUE")
117+
return enabled
118+
100119
}

0 commit comments

Comments
 (0)