Merge pull request #2031 from hairyhenderson/check-vtx-darwin-1983

Adding support for darwin to IsVTXDisabled
This commit is contained in:
Nathan LeClaire 2015-10-21 11:26:28 -07:00
commit 56acdcf5ae
4 changed files with 50 additions and 18 deletions

View File

@ -187,24 +187,6 @@ func (d *Driver) PreCreateCheck() error {
return d.vbm()
}
// IsVTXDisabled checks if VT-X is disabled in the BIOS. If it is, the vm will fail to start.
// If we can't be sure it is disabled, we carry on and will check the vm logs after it's started.
func (d *Driver) IsVTXDisabled() bool {
if runtime.GOOS == "windows" {
output, err := cmdOutput("wmic", "cpu", "get", "VirtualizationFirmwareEnabled")
if err != nil {
log.Debugf("Couldn't check that VT-X/AMD-v is enabled. Will check that the vm is properly created: %v", err)
return false
}
disabled := strings.Contains(output, "FALSE")
return disabled
}
// TODO: linux and OSX
return false
}
// cmdOutput runs a shell command and returns its output.
func cmdOutput(name string, args ...string) (string, error) {
cmd := exec.Command(name, args...)

View File

@ -0,0 +1,22 @@
package virtualbox
import (
"strings"
"syscall"
"github.com/docker/machine/libmachine/log"
)
// IsVTXDisabled checks if VT-X is disabled in the BIOS. If it is, the vm will fail to start.
// If we can't be sure it is disabled, we carry on and will check the vm logs after it's started.
func (d *Driver) IsVTXDisabled() bool {
errmsg := "Couldn't check that VT-X/AMD-v is enabled. Will check that the vm is properly created: %v"
features, err := syscall.Sysctl("machdep.cpu.features")
if err != nil {
log.Debugf(errmsg, err)
return false
}
disabled := !strings.Contains(features, "VMX")
return disabled
}

View File

@ -0,0 +1,7 @@
package virtualbox
// IsVTXDisabled checks if VT-X is disabled in the BIOS. If it is, the vm will fail to start.
// If we can't be sure it is disabled, we carry on and will check the vm logs after it's started.
func (d *Driver) IsVTXDisabled() bool {
return false
}

View File

@ -0,0 +1,21 @@
package virtualbox
import (
"strings"
"github.com/docker/machine/libmachine/log"
)
// IsVTXDisabled checks if VT-X is disabled in the BIOS. If it is, the vm will fail to start.
// If we can't be sure it is disabled, we carry on and will check the vm logs after it's started.
func (d *Driver) IsVTXDisabled() bool {
errmsg := "Couldn't check that VT-X/AMD-v is enabled. Will check that the vm is properly created: %v"
output, err := cmdOutput("wmic", "cpu", "get", "VirtualizationFirmwareEnabled")
if err != nil {
log.Debugf(errmsg, err)
return false
}
disabled := strings.Contains(output, "FALSE")
return disabled
}