From 3355b662410e41b0fafd8689e7c2fcfe452b5b3a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 17 Nov 2010 23:19:07 +0000 Subject: [PATCH] - client and scheduler: a client host may have multiple VM systems installed. TODO: check for VirtualBox on Mac, Linux svn path=/trunk/boinc/; revision=22704 --- checkin_notes | 14 ++++++++++++++ client/client_state.cpp | 6 +++--- client/hostinfo_win.cpp | 39 +++++++++++++++++++-------------------- db/boinc_db.h | 3 +-- lib/hostinfo.cpp | 26 +++++++++++++------------- lib/hostinfo.h | 9 +++++++-- sched/sched_types.cpp | 3 +-- 7 files changed, 58 insertions(+), 42 deletions(-) diff --git a/checkin_notes b/checkin_notes index 417a8c963d..3d213bee45 100644 --- a/checkin_notes +++ b/checkin_notes @@ -8137,3 +8137,17 @@ Rom 17 Nov 2010 boinc_db.h sched/ sched_types.cpp + +David 17 Nov 2010 + - client and scheduler: a client host may have multiple VM systems installed. + TODO: check for VirtualBox on Mac, Linux + + client/ + client_state.cpp + hostinfo_win.cpp + db/ + boinc_db.h + lib/ + hostinfo.cpp,h + sched/ + sched_types.cpp diff --git a/client/client_state.cpp b/client/client_state.cpp index 59137bbb70..7d88ed352a 100644 --- a/client/client_state.cpp +++ b/client/client_state.cpp @@ -188,10 +188,10 @@ void CLIENT_STATE::show_host_info() { tz<0?"":"+", tz ); - if (strlen(host_info.vm_version)) { + if (strlen(host_info.virtualbox_version)) { msg_printf(NULL, MSG_INFO, - "Detected: %s %s", - host_info.vm_name, host_info.vm_version + "VirtualBox version: %s", + host_info.virtualbox_version ); } } diff --git a/client/hostinfo_win.cpp b/client/hostinfo_win.cpp index 1b4f023955..45fb785464 100644 --- a/client/hostinfo_win.cpp +++ b/client/hostinfo_win.cpp @@ -1058,7 +1058,6 @@ int get_processor_info( // detect the network usage totals for the host. // int get_network_usage_totals(unsigned int& total_received, unsigned int& total_sent) { - // Declare and initialize variables. int i; int iRetVal = 0; DWORD dwSize = 0; @@ -1104,12 +1103,9 @@ int get_network_usage_totals(unsigned int& total_received, unsigned int& total_s } -// Check, if any, virtual machine technology is supported on the host +// see if Virtualbox is installed // -int get_virtualmachine_information( - char* vm_name, int /*vm_name_size*/, char* vm_version, int vm_version_size -) -{ +int HOST_INFO::get_virtualbox_version() { HKEY hKey; char szInstallDir[256]; char szVersion[256]; @@ -1117,24 +1113,29 @@ int get_virtualmachine_information( DWORD dwVersion = sizeof(szVersion); LONG lRet; + strcpy(virtualbox_version, ""); + lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\Oracle\\VirtualBox", - 0, KEY_QUERY_VALUE, &hKey ); - if( lRet == ERROR_SUCCESS ) { + 0, KEY_QUERY_VALUE, &hKey + ); + if (lRet == ERROR_SUCCESS) { + lRet = RegQueryValueEx(hKey, "InstallDir", NULL, NULL, + (LPBYTE) szInstallDir, &dwInstallDir + ); + if((lRet != ERROR_SUCCESS) || (dwInstallDir > sizeof(szInstallDir))) { + return 1; + } - lRet = RegQueryValueEx( hKey, "InstallDir", NULL, NULL, - (LPBYTE) szInstallDir, &dwInstallDir); - if( (lRet != ERROR_SUCCESS) || (dwInstallDir > sizeof(szInstallDir)) ) return 1; - - lRet = RegQueryValueEx( hKey, "Version", NULL, NULL, - (LPBYTE) szVersion, &dwVersion); - if( (lRet != ERROR_SUCCESS) || (dwVersion > sizeof(szVersion)) ) return 1; + lRet = RegQueryValueEx( + hKey, "Version", NULL, NULL, (LPBYTE) szVersion, &dwVersion + ); + if((lRet != ERROR_SUCCESS) || (dwVersion > sizeof(szVersion))) return 1; strncat(szInstallDir, "\\virtualbox.exe", sizeof(szInstallDir) - strlen(szInstallDir)); if (boinc_file_exists(szInstallDir)) { - strcpy(vm_name, "VirtualBox"); - strncpy(vm_version, szVersion, vm_version_size - strlen(szVersion)); + safe_strcpy(virtualbox_version, szVersion); } } @@ -1152,9 +1153,7 @@ int HOST_INFO::get_host_info() { get_os_information( os_name, sizeof(os_name), os_version, sizeof(os_version) ); - get_virtualmachine_information( - vm_name, sizeof(vm_name), vm_version, sizeof(vm_version) - ); + get_virtualbox_version(); get_processor_info( p_vendor, sizeof(p_vendor), p_model, sizeof(p_model), diff --git a/db/boinc_db.h b/db/boinc_db.h index 2751e7fa26..9ac420484a 100644 --- a/db/boinc_db.h +++ b/db/boinc_db.h @@ -334,8 +334,7 @@ struct HOST { // the following not stored in DB // char p_features[1024]; - char vm_name[256]; - char vm_version[256]; + char virtualbox_version[256]; int parse(FILE*); int parse_time_stats(FILE*); diff --git a/lib/hostinfo.cpp b/lib/hostinfo.cpp index 572671bf13..c9684f32c9 100644 --- a/lib/hostinfo.cpp +++ b/lib/hostinfo.cpp @@ -68,8 +68,7 @@ void HOST_INFO::clear_host_info() { strcpy(os_name, ""); strcpy(os_version, ""); - strcpy(vm_name, ""); - strcpy(vm_version, ""); + strcpy(virtualbox_version, ""); coprocs.clear(); } @@ -112,8 +111,7 @@ int HOST_INFO::parse(MIOFILE& in, bool benchmarks_only) { else if (parse_double(buf, "", d_free)) continue; else if (parse_str(buf, "", os_name, sizeof(os_name))) continue; else if (parse_str(buf, "", os_version, sizeof(os_version))) continue; - else if (parse_str(buf, "", vm_name, sizeof(vm_name))) continue; - else if (parse_str(buf, "", vm_version, sizeof(vm_version))) continue; + else if (parse_str(buf, "", virtualbox_version, sizeof(virtualbox_version))) continue; else if (match_tag(buf, "")) { coprocs.parse(in); } @@ -131,7 +129,7 @@ int HOST_INFO::parse(MIOFILE& in, bool benchmarks_only) { int HOST_INFO::write( MIOFILE& out, bool include_net_info, bool include_coprocs ) { - char pv[265], pm[256], pf[256], osn[256], osv[256], vmn[256], vmv[256]; + char pv[265], pm[256], pf[256], osn[256], osv[256]; out.printf( "\n" " %d\n", @@ -150,8 +148,6 @@ int HOST_INFO::write( xml_escape(p_features, pf, sizeof(pf)); xml_escape(os_name, osn, sizeof(osn)); xml_escape(os_version, osv, sizeof(osv)); - xml_escape(vm_name, vmn, sizeof(vmn)); - xml_escape(vm_version, vmv, sizeof(vmv)); out.printf( " %s\n" " %d\n" @@ -168,9 +164,7 @@ int HOST_INFO::write( " %f\n" " %f\n" " %s\n" - " %s\n" - " %s\n" - " %s\n", + " %s\n", host_cpid, p_ncpus, pv, @@ -186,10 +180,16 @@ int HOST_INFO::write( d_total, d_free, osn, - osv, - vmn, - vmv + osv ); + if (strlen(virtualbox_version)) { + char buf[256]; + xml_escape(virtualbox_version, buf, sizeof(buf)); + out.printf( + " %s\n", + buf + ); + } if (include_coprocs) { coprocs.write_xml(out, false); } diff --git a/lib/hostinfo.h b/lib/hostinfo.h index ecf7e1b688..824117fcf7 100644 --- a/lib/hostinfo.h +++ b/lib/hostinfo.h @@ -31,6 +31,8 @@ #include "miofile.h" #include "coproc.h" +// if you add fields, update clear_host_info() + class HOST_INFO { public: int timezone; // local STANDARD time - UTC time (in seconds) @@ -58,8 +60,10 @@ public: char os_name[256]; char os_version[256]; - char vm_name[256]; - char vm_version[256]; + // the following are non-empty if that VM system is installed + // + char virtualbox_version[256]; + // ... add entries for VMWare, others COPROCS coprocs; @@ -78,6 +82,7 @@ public: #endif int get_host_info(); int get_local_network_info(); + int get_virtualbox_version(); void clear_host_info(); void make_random_string(const char* salt, char* out); void generate_host_cpid(); diff --git a/sched/sched_types.cpp b/sched/sched_types.cpp index aaeff0b694..7d1a51ae3b 100644 --- a/sched/sched_types.cpp +++ b/sched/sched_types.cpp @@ -1170,8 +1170,7 @@ int HOST::parse(FILE* fin) { if (parse_double(buf, "", n_bwup)) continue; if (parse_double(buf, "", n_bwdown)) continue; if (parse_str(buf, "", p_features, sizeof(p_features))) continue; - if (parse_str(buf, "", vm_name, sizeof(vm_name))) continue; - if (parse_str(buf, "", vm_version, sizeof(vm_version))) continue; + if (parse_str(buf, "", virtualbox_version, sizeof(virtualbox_version))) continue; // parse deprecated fields to avoid error messages //