From 4820cb5436cc98c15c39fac58e2220a1db8a8cc4 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Fri, 20 Sep 2013 10:09:14 -0400 Subject: [PATCH 1/5] VBOX: Make sure the startup banner and feature dump happen after the boinc_init_options call so that stderr is redirected. --- samples/vboxwrapper/vboxwrapper.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/samples/vboxwrapper/vboxwrapper.cpp b/samples/vboxwrapper/vboxwrapper.cpp index 764accaf48..890a67e9e3 100644 --- a/samples/vboxwrapper/vboxwrapper.cpp +++ b/samples/vboxwrapper/vboxwrapper.cpp @@ -399,12 +399,26 @@ int main(int argc, char** argv) { } } + memset(&boinc_options, 0, sizeof(boinc_options)); + boinc_options.main_program = true; + boinc_options.check_heartbeat = true; + boinc_options.handle_process_control = true; + boinc_init_options(&boinc_options); + + // Prepare environment for detecting system conditions + // + boinc_get_init_data_p(&aid); + + // Log banner + // fprintf( stderr, "%s vboxwrapper: starting\n", vboxwrapper_msg_prefix(buf, sizeof(buf)) ); + // Log important information + // #if defined(_WIN32) && defined(USE_WINSOCK) WSADATA wsdata; retval = WSAStartup( MAKEWORD( 1, 1 ), &wsdata); @@ -419,11 +433,6 @@ int main(int argc, char** argv) { } #endif - memset(&boinc_options, 0, sizeof(boinc_options)); - boinc_options.main_program = true; - boinc_options.check_heartbeat = true; - boinc_options.handle_process_control = true; - if (trickle_period > 0.0) { fprintf( stderr, @@ -433,12 +442,6 @@ int main(int argc, char** argv) { boinc_options.handle_trickle_ups = true; } - boinc_init_options(&boinc_options); - - // Prepare environment for detecting system conditions - // - boinc_get_init_data_p(&aid); - // Check for architecture incompatibilities // #if defined(_WIN32) && defined(_M_IX86) From 37db65907ca8c5318ef0f1f153cf8b618c2439d7 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Fri, 20 Sep 2013 11:18:41 -0400 Subject: [PATCH 2/5] VBOX: Base the VM name on the MD5 hash of the result name instead of the slot id. --- samples/vboxwrapper/vboxwrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/vboxwrapper/vboxwrapper.cpp b/samples/vboxwrapper/vboxwrapper.cpp index 890a67e9e3..d4dcef6262 100644 --- a/samples/vboxwrapper/vboxwrapper.cpp +++ b/samples/vboxwrapper/vboxwrapper.cpp @@ -64,6 +64,7 @@ #include "boinc_api.h" #include "diagnostics.h" #include "filesys.h" +#include "md5_file.h" #include "parse.h" #include "str_util.h" #include "str_replace.h" @@ -585,8 +586,7 @@ int main(int argc, char** argv) { vm.floppy_image_filename = buf; } } else { - sprintf(buf, "_slot_%d", aid.slot); - vm.vm_master_name += buf; + vm.vm_master_name += md5_string(std::string(aid.result_name)).substr(0, 16); vm.vm_master_description = aid.result_name; if (vm.enable_floppyio) { sprintf(buf, "%s_%d.%s", FLOPPY_IMAGE_FILENAME, aid.slot, FLOPPY_IMAGE_FILENAME_EXTENSION); From 3e4a8f2a280e06b98c0a72842fae15fa6510b626 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Fri, 20 Sep 2013 11:24:42 -0400 Subject: [PATCH 3/5] WINBUILD: Increment vboxwrappers version number --- win_build/vboxwrapper.vcproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/win_build/vboxwrapper.vcproj b/win_build/vboxwrapper.vcproj index 63f8a56f4e..73709b368b 100644 --- a/win_build/vboxwrapper.vcproj +++ b/win_build/vboxwrapper.vcproj @@ -82,13 +82,13 @@ @@ -183,13 +183,13 @@ From 8428f942de83de30cb563ed66a2b4229a46a7d3c Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Fri, 20 Sep 2013 14:46:26 -0400 Subject: [PATCH 4/5] lib: On Windows, if the registry key that defines where the data directory is missing, check to see if the default directory exists anyway. If the directory exists change the current working directory over to it. --- lib/win_util.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/win_util.cpp b/lib/win_util.cpp index 394940bd15..65ff92ee98 100644 --- a/lib/win_util.cpp +++ b/lib/win_util.cpp @@ -26,6 +26,8 @@ #endif #include "diagnostics.h" +#include "util.h" +#include "filesys.h" #include "win_util.h" /** @@ -749,21 +751,22 @@ void chdir_to_data_dir() { LONG lReturnValue; HKEY hkSetupHive; LPTSTR lpszRegistryValue = NULL; + char szPath[MAX_PATH]; DWORD dwSize = 0; // change the current directory to the boinc data directory if it exists - lReturnValue = RegOpenKeyEx( + lReturnValue = RegOpenKeyExA( HKEY_LOCAL_MACHINE, - _T("SOFTWARE\\Space Sciences Laboratory, U.C. Berkeley\\BOINC Setup"), + "SOFTWARE\\Space Sciences Laboratory, U.C. Berkeley\\BOINC Setup", 0, KEY_READ, &hkSetupHive ); if (lReturnValue == ERROR_SUCCESS) { // How large does our buffer need to be? - lReturnValue = RegQueryValueEx( + lReturnValue = RegQueryValueExA( hkSetupHive, - _T("DATADIR"), + "DATADIR", NULL, NULL, NULL, @@ -775,16 +778,23 @@ void chdir_to_data_dir() { (*lpszRegistryValue) = NULL; // Now get the data - lReturnValue = RegQueryValueEx( + lReturnValue = RegQueryValueExA( hkSetupHive, - _T("DATADIR"), + "DATADIR", NULL, NULL, (LPBYTE)lpszRegistryValue, &dwSize ); - SetCurrentDirectory(lpszRegistryValue); + SetCurrentDirectoryA(lpszRegistryValue); + } + } else { + if (SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_COMMON_APPDATA|CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, szPath))) { + strncat(szPath, "\\boinc", (sizeof(szPath) - strlen(szPath))); + if (boinc_file_exists(szPath)) { + SetCurrentDirectoryA(szPath); + } } } From f44c260e674cb429d97c10cb5411e40d0614e181 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Fri, 20 Sep 2013 14:49:07 -0400 Subject: [PATCH 5/5] lib: A little code cleanup missed from the previous commit --- lib/win_util.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/win_util.cpp b/lib/win_util.cpp index 65ff92ee98..ab675b5332 100644 --- a/lib/win_util.cpp +++ b/lib/win_util.cpp @@ -750,7 +750,7 @@ GetAccountSid( void chdir_to_data_dir() { LONG lReturnValue; HKEY hkSetupHive; - LPTSTR lpszRegistryValue = NULL; + LPSTR lpszRegistryValue = NULL; char szPath[MAX_PATH]; DWORD dwSize = 0; @@ -774,7 +774,7 @@ void chdir_to_data_dir() { ); if (lReturnValue != ERROR_FILE_NOT_FOUND) { // Allocate the buffer space. - lpszRegistryValue = (LPTSTR) malloc(dwSize); + lpszRegistryValue = (LPSTR) malloc(dwSize); (*lpszRegistryValue) = NULL; // Now get the data