From ac45f88ce32d87da28237fe9e268097e89490bf1 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Fri, 18 Dec 2015 11:44:37 +0100 Subject: [PATCH] Don't create the VM if no hardware virtualization Signed-off-by: David Gageot --- docs/drivers/virtualbox.md | 2 ++ drivers/virtualbox/virtualbox.go | 15 +++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/drivers/virtualbox.md b/docs/drivers/virtualbox.md index 471e19f41b..d0aa87ab3c 100644 --- a/docs/drivers/virtualbox.md +++ b/docs/drivers/virtualbox.md @@ -36,6 +36,7 @@ Options: - `--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-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 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-no-share` | `VIRTUALBOX_NO_SHARE` | `false` | | `--virtualbox-dns-proxy` | `VIRTUALBOX_DNS_PROXY` | `false` | +| `--virtualbox-no-vtx-check` | `VIRTUALBOX_NO_VTX_CHECK` | `false` | ## Known Issues diff --git a/drivers/virtualbox/virtualbox.go b/drivers/virtualbox/virtualbox.go index a5eed341df..a9c7eccbc9 100644 --- a/drivers/virtualbox/virtualbox.go +++ b/drivers/virtualbox/virtualbox.go @@ -58,6 +58,7 @@ type Driver struct { HostOnlyPromiscMode string NoShare bool DNSProxy bool + NoVTXCheck bool } // 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", 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.NoShare = flags.Bool("virtualbox-no-share") d.DNSProxy = flags.Bool("virtualbox-dns-proxy") + d.NoVTXCheck = flags.Bool("virtualbox-no-vtx-check") return nil } @@ -208,12 +215,8 @@ func (d *Driver) PreCreateCheck() error { return err } - if d.IsVTXDisabled() { - // Let's log a warning to warn the user. When the vm is started, logs - // 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.") + if !d.NoVTXCheck && d.IsVTXDisabled() { + return ErrMustEnableVTX } return nil