From 8f3249720f54e578fb9fb7f20115b8061aef2d13 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Tue, 13 Sep 2011 21:49:42 +0000 Subject: [PATCH] - VBOX: Don't attempt to stop a VM that is already shut down. samples/vboxwrapper/ vbox.cpp svn path=/trunk/boinc/; revision=24185 --- checkin_notes | 6 ++++++ samples/vboxwrapper/vbox.cpp | 36 ++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/checkin_notes b/checkin_notes index 471609d6cf..1dd4d8e6a4 100644 --- a/checkin_notes +++ b/checkin_notes @@ -5944,3 +5944,9 @@ Rom 13 Sept 2011 samples/vboxwrapper/ vbox.cpp + +Rom 13 Sept 2011 + - VBOX: Don't attempt to stop a VM that is already shut down. + + samples/vboxwrapper/ + vbox.cpp diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp index c8252d0708..d78559b47c 100644 --- a/samples/vboxwrapper/vbox.cpp +++ b/samples/vboxwrapper/vbox.cpp @@ -778,23 +778,31 @@ int VBOX_VM::stop() { char buf[256]; int retval; - fprintf( - stderr, - "%s Stopping virtual machine.\n", - boinc_msg_prefix(buf, sizeof(buf)) - ); - command = "controlvm \"" + vm_name + "\" savestate"; - retval = vbm_popen(command, output); - if (retval) { + if (is_running()) { fprintf( stderr, - "%s Error stopping virtual machine! rc = 0x%x\nCommand:\n%s\nOutput:\n%s\n", - boinc_msg_prefix(buf, sizeof(buf)), - retval, - command.c_str(), - output.c_str() + "%s Stopping virtual machine.\n", + boinc_msg_prefix(buf, sizeof(buf)) + ); + command = "controlvm \"" + vm_name + "\" savestate"; + retval = vbm_popen(command, output); + if (retval) { + fprintf( + stderr, + "%s Error stopping virtual machine! rc = 0x%x\nCommand:\n%s\nOutput:\n%s\n", + boinc_msg_prefix(buf, sizeof(buf)), + retval, + command.c_str(), + output.c_str() + ); + return retval; + } + } else { + fprintf( + stderr, + "%s Virtual machine is already in a stopped state.\n", + boinc_msg_prefix(buf, sizeof(buf)) ); - return retval; } return 0; }