2015-10-20 19:24:10 -04:00
|
|
|
package virtualbox
|
|
|
|
|
|
2015-10-27 22:13:30 -07:00
|
|
|
import (
|
2015-11-12 23:42:28 -05:00
|
|
|
"bytes"
|
|
|
|
|
"io/ioutil"
|
2015-10-27 22:13:30 -07:00
|
|
|
|
|
|
|
|
"github.com/docker/machine/libmachine/log"
|
|
|
|
|
)
|
|
|
|
|
|
2015-10-20 19:24:10 -04:00
|
|
|
// 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.
|
2015-12-06 22:02:54 +01:00
|
|
|
// We want to check that either vmx or svm flags are present in /proc/cpuinfo.
|
2015-10-20 19:24:10 -04:00
|
|
|
func (d *Driver) IsVTXDisabled() bool {
|
2015-11-24 16:00:43 +01:00
|
|
|
cpuinfo, err := ioutil.ReadFile("/proc/cpuinfo")
|
2015-10-27 22:13:30 -07:00
|
|
|
if err != nil {
|
2015-11-24 16:00:43 +01:00
|
|
|
log.Debugf("Couldn't check that VT-X/AMD-v is enabled. Will check that the vm is properly created: %v", err)
|
2015-10-27 22:13:30 -07:00
|
|
|
return false
|
|
|
|
|
}
|
2015-11-24 16:00:43 +01:00
|
|
|
return isVTXDisabled(cpuinfo)
|
|
|
|
|
}
|
2015-10-27 22:13:30 -07:00
|
|
|
|
2015-11-24 16:00:43 +01:00
|
|
|
func isVTXDisabled(cpuinfo []byte) bool {
|
|
|
|
|
features := [2][]byte{
|
|
|
|
|
{'v', 'm', 'x'},
|
2015-12-06 22:02:54 +01:00
|
|
|
{'s', 'v', 'm'},
|
2015-11-24 16:00:43 +01:00
|
|
|
}
|
2015-11-12 23:42:28 -05:00
|
|
|
for _, v := range features {
|
2015-11-24 16:00:43 +01:00
|
|
|
if bytes.Contains(cpuinfo, v) {
|
2015-11-12 23:42:28 -05:00
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true
|
2015-10-20 19:24:10 -04:00
|
|
|
}
|
2015-11-06 15:34:25 +01:00
|
|
|
|
|
|
|
|
func detectVBoxManageCmd() string {
|
|
|
|
|
return detectVBoxManageCmdInPath()
|
|
|
|
|
}
|
2015-11-24 16:00:19 +01:00
|
|
|
|
|
|
|
|
func getShareDriveAndName() (string, string) {
|
|
|
|
|
return "hosthome", "/home"
|
|
|
|
|
}
|
2015-12-28 11:18:56 +01:00
|
|
|
|
|
|
|
|
func isHyperVInstalled() bool {
|
|
|
|
|
return false
|
|
|
|
|
}
|