builder/virtualbox: only power off the machine if it isrunning

This commit is contained in:
Mitchell Hashimoto 2013-06-23 22:00:40 -07:00
parent bdd60fe914
commit 0f376457e3
1 changed files with 5 additions and 2 deletions

View File

@ -48,7 +48,10 @@ func (s *stepRun) Cleanup(state map[string]interface{}) {
driver := state["driver"].(Driver) driver := state["driver"].(Driver)
ui := state["ui"].(packer.Ui) ui := state["ui"].(packer.Ui)
if err := driver.VBoxManage("controlvm", s.vmName, "poweroff"); err != nil {
ui.Error(fmt.Sprintf("Error shutting down VM: %s", err)) if running, _ := driver.IsRunning(s.vmName); running {
if err := driver.VBoxManage("controlvm", s.vmName, "poweroff"); err != nil {
ui.Error(fmt.Sprintf("Error shutting down VM: %s", err))
}
} }
} }