From 42ad416c0aea6299bd9c2010ba22cdb8ff08a6f9 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Thu, 10 Dec 2015 15:44:37 +0100 Subject: [PATCH] FIX #2479 Warn on VirtualBox version Signed-off-by: David Gageot --- docs/drivers/virtualbox.md | 4 +++- drivers/virtualbox/vbm.go | 6 +++++- drivers/virtualbox/vbm_test.go | 4 ++-- drivers/virtualbox/virtualbox.go | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/drivers/virtualbox.md b/docs/drivers/virtualbox.md index f8ce83a157..64992d86f2 100644 --- a/docs/drivers/virtualbox.md +++ b/docs/drivers/virtualbox.md @@ -11,7 +11,9 @@ parent="smn_machine_drivers" # Oracle VirtualBox Create machines locally using [VirtualBox](https://www.virtualbox.org/). -This driver requires VirtualBox 4+ to be installed on your host. +This driver requires VirtualBox 5+ to be installed on your host. +Using VirtualBox 4+ should work but will give you a warning. Older versions +will refuse to work. $ docker-machine create --driver=virtualbox vbox-test diff --git a/drivers/virtualbox/vbm.go b/drivers/virtualbox/vbm.go index 3f05b3f72b..09c1e78f96 100644 --- a/drivers/virtualbox/vbm.go +++ b/drivers/virtualbox/vbm.go @@ -79,7 +79,11 @@ func (v *VBoxCmdManager) vbmOutErr(args ...string) (string, string, error) { func checkVBoxManageVersion(version string) error { if !strings.HasPrefix(version, "5.") && !strings.HasPrefix(version, "4.") { - return fmt.Errorf("We support Virtualbox starting with version 4. Your VirtualBox install is %q. Please upgrade at https://www.virtualbox.org", version) + return fmt.Errorf("We support Virtualbox starting with version 5. Your VirtualBox install is %q. Please upgrade at https://www.virtualbox.org", version) + } + + if !strings.HasPrefix(version, "5.") { + log.Warnf("You are using version %s of VirtualBox. If you encouter issues, you might want to upgrade to version 5 at https://www.virtualbox.org", version) } return nil diff --git a/drivers/virtualbox/vbm_test.go b/drivers/virtualbox/vbm_test.go index bd82f4c7a0..ddfd078ad5 100644 --- a/drivers/virtualbox/vbm_test.go +++ b/drivers/virtualbox/vbm_test.go @@ -30,8 +30,8 @@ func TestCheckVBoxManageVersionInvalid(t *testing.T) { version string expectedError string }{ - {"3.9", `We support Virtualbox starting with version 4. Your VirtualBox install is "3.9". Please upgrade at https://www.virtualbox.org`}, - {"", `We support Virtualbox starting with version 4. Your VirtualBox install is "". Please upgrade at https://www.virtualbox.org`}, + {"3.9", `We support Virtualbox starting with version 5. Your VirtualBox install is "3.9". Please upgrade at https://www.virtualbox.org`}, + {"", `We support Virtualbox starting with version 5. Your VirtualBox install is "". Please upgrade at https://www.virtualbox.org`}, } for _, test := range tests { diff --git a/drivers/virtualbox/virtualbox.go b/drivers/virtualbox/virtualbox.go index 483b68462b..a5eed341df 100644 --- a/drivers/virtualbox/virtualbox.go +++ b/drivers/virtualbox/virtualbox.go @@ -204,7 +204,7 @@ func (d *Driver) PreCreateCheck() error { } // Check that VBoxManage is of a supported version - if err = checkVBoxManageVersion(version); err != nil { + if err = checkVBoxManageVersion(strings.TrimSpace(version)); err != nil { return err }