forked from rancher/machine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtx.go
28 lines (24 loc) · 775 Bytes
/
vtx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package virtualbox
import "strings"
// IsVTXDisabledInTheVM checks if VT-X is disabled in the started vm.
func (d *Driver) IsVTXDisabledInTheVM() (bool, error) {
lines, err := d.readVBoxLog()
if err != nil {
return true, err
}
for _, line := range lines {
if strings.Contains(line, "VT-x is disabled") && !strings.Contains(line, "Falling back to raw-mode: VT-x is disabled in the BIOS for all CPU modes") {
return true, nil
}
if strings.Contains(line, "the host CPU does NOT support HW virtualization") {
return true, nil
}
if strings.Contains(line, "VERR_VMX_UNABLE_TO_START_VM") {
return true, nil
}
if strings.Contains(line, "Power up failed") && strings.Contains(line, "VERR_VMX_NO_VMX") {
return true, nil
}
}
return false, nil
}