From f54f09d7a3e49dc97e8c8a1ac7f8b6e3febf8210 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 5 Sep 2014 09:57:30 -0700 Subject: [PATCH] builder/virtualbox: detect vboxmanage errors with zero code [GH-1119] --- CHANGELOG.md | 2 ++ builder/virtualbox/common/driver_4_2.go | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad8430ed8..d2f387cd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,8 @@ BUG FIXES: * builder/virtualbox/all: Seed RNG to avoid same ports. [GH-1386] * builder/virtualbox/all: Better error if guest additions URL couldn't be detected. [GH-1439] + * builder/virtualbox/all: Detect errors even when `VBoxManage` exits + with a zero exit code. [GH-1119] * builder/virtualbox/iso: Append timestamp to default name for parallel builds. [GH-1365] * builder/vmware/all: `ssh_host` accepts templates. [GH-1396] diff --git a/builder/virtualbox/common/driver_4_2.go b/builder/virtualbox/common/driver_4_2.go index 901822174..beb6dac9d 100644 --- a/builder/virtualbox/common/driver_4_2.go +++ b/builder/virtualbox/common/driver_4_2.go @@ -157,6 +157,13 @@ func (d *VBox42Driver) VBoxManage(args ...string) error { err = fmt.Errorf("VBoxManage error: %s", stderrString) } + if err == nil { + m, _ := regexp.MatchString("VBoxManage([.a-z]+?): error:", stderrString) + if m { + err = fmt.Errorf("VBoxManage error: %s", stderrString) + } + } + log.Printf("stdout: %s", stdoutString) log.Printf("stderr: %s", stderrString)