Don't create the VM if no hardware virtualization

Signed-off-by: David Gageot <david@gageot.net>
This commit is contained in:
David Gageot 2015-12-18 11:44:37 +01:00
parent 0a74068b11
commit ac45f88ce3
2 changed files with 11 additions and 6 deletions

View File

@ -36,6 +36,7 @@ Options:
- `--virtualbox-hostonly-nicpromisc`: Host Only Network Adapter Promiscuous Mode. Possible options are deny , allow-vms, allow-all - `--virtualbox-hostonly-nicpromisc`: Host Only Network Adapter Promiscuous Mode. Possible options are deny , allow-vms, allow-all
- `--virtualbox-no-share`: Disable the mount of your home directory - `--virtualbox-no-share`: Disable the mount of your home directory
- `--virtualbox-dns-proxy`: Proxy all DNS requests to the host (Boolean value, default to false) - `--virtualbox-dns-proxy`: Proxy all DNS requests to the host (Boolean value, default to false)
- `--virtualbox-no-vtx-check`: Disable checking for the availability of hardware virtualization before the vm is started
The `--virtualbox-boot2docker-url` flag takes a few different forms. By The `--virtualbox-boot2docker-url` flag takes a few different forms. By
default, if no value is specified for this flag, Machine will check locally for default, if no value is specified for this flag, Machine will check locally for
@ -78,6 +79,7 @@ Environment variables and default values:
| `--virtualbox-hostonly-nicpromisc` | `VIRTUALBOX_HOSTONLY_NIC_PROMISC` | `deny` | | `--virtualbox-hostonly-nicpromisc` | `VIRTUALBOX_HOSTONLY_NIC_PROMISC` | `deny` |
| `--virtualbox-no-share` | `VIRTUALBOX_NO_SHARE` | `false` | | `--virtualbox-no-share` | `VIRTUALBOX_NO_SHARE` | `false` |
| `--virtualbox-dns-proxy` | `VIRTUALBOX_DNS_PROXY` | `false` | | `--virtualbox-dns-proxy` | `VIRTUALBOX_DNS_PROXY` | `false` |
| `--virtualbox-no-vtx-check` | `VIRTUALBOX_NO_VTX_CHECK` | `false` |
## Known Issues ## Known Issues

View File

@ -58,6 +58,7 @@ type Driver struct {
HostOnlyPromiscMode string HostOnlyPromiscMode string
NoShare bool NoShare bool
DNSProxy bool DNSProxy bool
NoVTXCheck bool
} }
// NewDriver creates a new VirtualBox driver with default settings. // NewDriver creates a new VirtualBox driver with default settings.
@ -144,6 +145,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Usage: "Proxy all DNS requests to the host", Usage: "Proxy all DNS requests to the host",
EnvVar: "VIRTUALBOX_DNS_PROXY", EnvVar: "VIRTUALBOX_DNS_PROXY",
}, },
mcnflag.BoolFlag{
Name: "virtualbox-no-vtx-check",
Usage: "Disable checking for the availability of hardware virtualization before the vm is started",
EnvVar: "VIRTUALBOX_NO_VTX_CHECK",
},
} }
} }
@ -191,6 +197,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.HostOnlyPromiscMode = flags.String("virtualbox-hostonly-nicpromisc") d.HostOnlyPromiscMode = flags.String("virtualbox-hostonly-nicpromisc")
d.NoShare = flags.Bool("virtualbox-no-share") d.NoShare = flags.Bool("virtualbox-no-share")
d.DNSProxy = flags.Bool("virtualbox-dns-proxy") d.DNSProxy = flags.Bool("virtualbox-dns-proxy")
d.NoVTXCheck = flags.Bool("virtualbox-no-vtx-check")
return nil return nil
} }
@ -208,12 +215,8 @@ func (d *Driver) PreCreateCheck() error {
return err return err
} }
if d.IsVTXDisabled() { if !d.NoVTXCheck && d.IsVTXDisabled() {
// Let's log a warning to warn the user. When the vm is started, logs return ErrMustEnableVTX
// will be checked for an error anyway.
// We could fail right here but the method to check didn't prove being
// bulletproof.
log.Warn("This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory.")
} }
return nil return nil