From 56974bff7053f5e12157582fd909151cf6113ea8 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Sat, 5 Jan 2013 14:35:40 -0500 Subject: [PATCH] VBOX: If Detection of VirtualBox fails, declare it a temporary failure and reschedule after 24-hours. 6.10 and older do not detect if VirtualBox has been installed. If a VM job is assigned to a host running on an old client and the wrapper detects VirtualBox is not installed reschedule the job for execution at a later date. This prevents the client from requesting excessive amounts of work which will all fail. Eventually the job will error out when it passes its deadline. --- samples/vboxwrapper/vbox.cpp | 13 ++++++++++--- samples/vboxwrapper/vboxwrapper.cpp | 7 +++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp index 00c5f2eeeb..33a3b71b61 100644 --- a/samples/vboxwrapper/vbox.cpp +++ b/samples/vboxwrapper/vbox.cpp @@ -109,6 +109,7 @@ VBOX_VM::~VBOX_VM() { } int VBOX_VM::initialize() { + int rc = 0; string virtualbox_install_directory; string old_path; string new_path; @@ -120,7 +121,9 @@ int VBOX_VM::initialize() { char buf[256]; boinc_get_init_data_p(&aid); - get_install_directory(virtualbox_install_directory); + + rc = get_install_directory(virtualbox_install_directory); + if (rc) return rc; // Prep the environment so we can execute the vboxmanage application // @@ -1130,15 +1133,19 @@ int VBOX_VM::get_install_directory(string& virtualbox_install_directory ) { if (hkSetupHive) RegCloseKey(hkSetupHive); if (lpszRegistryValue) free(lpszRegistryValue); + if (virtualbox_install_directory.empty()) { + return 1; + } + return 0; #else virtualbox_install_directory = ""; -#endif return 0; +#endif } // Returns the current directory in which the executable resides. // -int VBOX_VM::get_slot_directory( string& dir ) { +int VBOX_VM::get_slot_directory(string& dir) { char slot_dir[256]; getcwd(slot_dir, sizeof(slot_dir)); diff --git a/samples/vboxwrapper/vboxwrapper.cpp b/samples/vboxwrapper/vboxwrapper.cpp index 1d86bbb7ae..cac73480fd 100644 --- a/samples/vboxwrapper/vboxwrapper.cpp +++ b/samples/vboxwrapper/vboxwrapper.cpp @@ -421,11 +421,10 @@ int main(int argc, char** argv) { if (retval) { fprintf( stderr, - "%s failed to initialize VM Hypervisor environment: %d\n", - vboxwrapper_msg_prefix(buf, sizeof(buf)), - retval + "%s couldn't detect VM Hypervisor, telling BOINC to reschedule execution for a later date.\n", + vboxwrapper_msg_prefix(buf, sizeof(buf)) ); - boinc_finish(retval); + boinc_temporary_exit(86400, "Detection of VM Hypervisor failed."); } // Check to see if the system is in a state in which we expect to be able to run