diff --git a/checkin_notes b/checkin_notes
index 72c60291ef..42ffaf33fe 100644
--- a/checkin_notes
+++ b/checkin_notes
@@ -7780,3 +7780,17 @@ David 18 Dec 2012
top_hosts.php
top_teams.php
top_users.php
+
+Rom 19 Dec 2012
+ - VBOX: Perform a quick check that the wrapper can communicate with
+ vboxsvc via vboxmanage before attempting anything else. If it
+ fails, get BOINC to reschedule task execution in 5 minutes.
+
+ NOTE: After a reboot it might take a few moments before everything
+ is in working order.
+
+ samples\vboxwrapper\
+ vbox.cpp, .h
+ vboxwrapper.cpp
+ win_build\
+ vboxwrapper.vcproj
diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp
index 5b48a185b1..33ae962a69 100644
--- a/samples/vboxwrapper/vbox.cpp
+++ b/samples/vboxwrapper/vbox.cpp
@@ -601,18 +601,21 @@ void VBOX_VM::poll(bool log_state) {
}
}
-bool VBOX_VM::is_hdd_registered() {
+// Attempt to detect any condition that would prevent VirtualBox from running a VM properly, like:
+// 1. The DCOM service not being started on Windows
+// 2. Vboxmanage not being able to communicate with vboxsvc for some reason
+//
+// Luckly both of the above conditions can be detected by attempting to detect the host information
+// via vboxmanage and it is cross platform.
+//
+bool VBOX_VM::is_system_ready() {
string command;
string output;
- string virtual_machine_root_dir;
- get_slot_directory(virtual_machine_root_dir);
+ command = "list hostinfo ";
- command = "showhdinfo \"" + virtual_machine_root_dir + "/" + image_filename + "\" ";
-
- if (vbm_popen(command, output, "hdd registration", false, false) == 0) {
- if ((output.find("VBOX_E_FILE_ERROR") == string::npos) && (output.find("VBOX_E_OBJECT_NOT_FOUND") == string::npos)) {
- // Error message not found in text
+ if (vbm_popen(command, output, "host info", false, false) == 0) {
+ if (output.find("Processor count:") != string::npos) {
return true;
}
}
@@ -635,6 +638,24 @@ bool VBOX_VM::is_registered() {
return false;
}
+bool VBOX_VM::is_hdd_registered() {
+ string command;
+ string output;
+ string virtual_machine_root_dir;
+
+ get_slot_directory(virtual_machine_root_dir);
+
+ command = "showhdinfo \"" + virtual_machine_root_dir + "/" + image_filename + "\" ";
+
+ if (vbm_popen(command, output, "hdd registration", false, false) == 0) {
+ if ((output.find("VBOX_E_FILE_ERROR") == string::npos) && (output.find("VBOX_E_OBJECT_NOT_FOUND") == string::npos)) {
+ // Error message not found in text
+ return true;
+ }
+ }
+ return false;
+}
+
bool VBOX_VM::is_extpack_installed() {
string command;
string output;
diff --git a/samples/vboxwrapper/vbox.h b/samples/vboxwrapper/vbox.h
index efe3e04ed2..9991fb9cb5 100644
--- a/samples/vboxwrapper/vbox.h
+++ b/samples/vboxwrapper/vbox.h
@@ -111,8 +111,9 @@ struct VBOX_VM {
void cleanup();
void poll(bool log_state = true);
- bool is_hdd_registered();
+ bool is_system_ready();
bool is_registered();
+ bool is_hdd_registered();
bool is_extpack_installed();
int register_vm();
diff --git a/samples/vboxwrapper/vboxwrapper.cpp b/samples/vboxwrapper/vboxwrapper.cpp
index 5f4cb58de5..e85bf15a5d 100644
--- a/samples/vboxwrapper/vboxwrapper.cpp
+++ b/samples/vboxwrapper/vboxwrapper.cpp
@@ -397,6 +397,19 @@ int main(int argc, char** argv) {
vboxwrapper_msg_prefix(buf, sizeof(buf))
);
+ // Check to see if the system is in a state in which we expect to be able to run
+ // VirtualBox successfully. Sometimes the system is in a wierd state after a
+ // reboot and the system needs a little bit of time.
+ //
+ if (!vm.is_system_ready()) {
+ fprintf(
+ stderr,
+ "%s couldn't communicate with VM Hypervisor, telling BOINC to reschedule execution for a later date.\n",
+ vboxwrapper_msg_prefix(buf, sizeof(buf))
+ );
+ boinc_temporary_exit(300, "Communication with VM Hypervisor failed.");
+ }
+
#if defined(_WIN32) && defined(USE_WINSOCK)
WSADATA wsdata;
retval = WSAStartup( MAKEWORD( 1, 1 ), &wsdata);
diff --git a/win_build/vboxwrapper.vcproj b/win_build/vboxwrapper.vcproj
index d624de84df..9edd0aaeba 100644
--- a/win_build/vboxwrapper.vcproj
+++ b/win_build/vboxwrapper.vcproj
@@ -81,13 +81,13 @@
@@ -182,13 +182,13 @@