Merge pull request #8096 from onematchfox/virtualbox-snapshot

fix(virtualbox-vm) LoadSnapshots should succeed even if machine has no snapshots
This commit is contained in:
Adrien Delorme 2019-09-12 13:18:46 +02:00 committed by GitHub
commit 2e58b807de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -252,18 +252,19 @@ func (d *VBox42Driver) LoadSnapshots(vmName string) (*VBoxSnapshot, error) {
} }
log.Printf("Executing LoadSnapshots: VM: %s", vmName) log.Printf("Executing LoadSnapshots: VM: %s", vmName)
var rootNode *VBoxSnapshot
stdoutString, err := d.VBoxManageWithOutput("snapshot", vmName, "list", "--machinereadable") stdoutString, err := d.VBoxManageWithOutput("snapshot", vmName, "list", "--machinereadable")
if stdoutString == "This machine does not have any snapshots" {
return rootNode, nil
}
if nil != err { if nil != err {
return nil, err return nil, err
} }
var rootNode *VBoxSnapshot
if stdoutString != "This machine does not have any snapshots" {
rootNode, err = ParseSnapshotData(stdoutString) rootNode, err = ParseSnapshotData(stdoutString)
if nil != err { if nil != err {
return nil, err return nil, err
} }
}
return rootNode, nil return rootNode, nil
} }