From 5b6dcb0c942ca7c138edb8f67bb9730093f81a73 Mon Sep 17 00:00:00 2001 From: Brian Fox Date: Thu, 12 Sep 2019 10:50:42 +0200 Subject: [PATCH] fix(virtualbox) LoadSnapshots should succeed even if VM has no snapshots --- builder/virtualbox/common/driver_4_2.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/builder/virtualbox/common/driver_4_2.go b/builder/virtualbox/common/driver_4_2.go index 1cc3e4ff9..03f119e94 100644 --- a/builder/virtualbox/common/driver_4_2.go +++ b/builder/virtualbox/common/driver_4_2.go @@ -252,17 +252,18 @@ func (d *VBox42Driver) LoadSnapshots(vmName string) (*VBoxSnapshot, error) { } log.Printf("Executing LoadSnapshots: VM: %s", vmName) + var rootNode *VBoxSnapshot stdoutString, err := d.VBoxManageWithOutput("snapshot", vmName, "list", "--machinereadable") + if stdoutString == "This machine does not have any snapshots" { + return rootNode, nil + } if nil != err { return nil, err } - var rootNode *VBoxSnapshot - if stdoutString != "This machine does not have any snapshots" { - rootNode, err = ParseSnapshotData(stdoutString) - if nil != err { - return nil, err - } + rootNode, err = ParseSnapshotData(stdoutString) + if nil != err { + return nil, err } return rootNode, nil