From f0ae0b832deafbea6ac6a79b20412db3e2ac7ecf Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Wed, 17 Nov 2010 20:08:18 +0000 Subject: [PATCH] - client: Add support to detect VirtualBox VM software. client/ client_state.cpp hostinfo_win.cpp lib/ hostinfo.cpp, .h svn path=/trunk/boinc/; revision=22702 --- checkin_notes | 10 ++++++++++ client/client_state.cpp | 7 +++++++ client/hostinfo_win.cpp | 42 ++++++++++++++++++++++++++++++++++++++++- lib/hostinfo.cpp | 17 ++++++++++++++--- lib/hostinfo.h | 3 +++ 5 files changed, 75 insertions(+), 4 deletions(-) diff --git a/checkin_notes b/checkin_notes index 40abfa58a6..02496034d6 100644 --- a/checkin_notes +++ b/checkin_notes @@ -8119,3 +8119,13 @@ David 17 Nov 2010 work_fetch.cpp html/ops/ team_export.php + +Rom 17 Nov 2010 + - client: Add support to detect VirtualBox VM software. + + client/ + client_state.cpp + hostinfo_win.cpp + lib/ + hostinfo.cpp, .h + \ No newline at end of file diff --git a/client/client_state.cpp b/client/client_state.cpp index d2b641f0e4..59137bbb70 100644 --- a/client/client_state.cpp +++ b/client/client_state.cpp @@ -187,6 +187,13 @@ void CLIENT_STATE::show_host_info() { msg_printf(0, MSG_INFO, "Local time is UTC %s%d hours", tz<0?"":"+", tz ); + + if (strlen(host_info.vm_version)) { + msg_printf(NULL, MSG_INFO, + "Detected: %s %s", + host_info.vm_name, host_info.vm_version + ); + } } static void check_no_apps(PROJECT* p) { diff --git a/client/hostinfo_win.cpp b/client/hostinfo_win.cpp index 94352bb38e..1b4f023955 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; @@ -1102,7 +1101,45 @@ int get_network_usage_totals(unsigned int& total_received, unsigned int& total_s } return iRetVal; +} + +// Check, if any, virtual machine technology is supported on the host +// +int get_virtualmachine_information( + char* vm_name, int /*vm_name_size*/, char* vm_version, int vm_version_size +) +{ + HKEY hKey; + char szInstallDir[256]; + char szVersion[256]; + DWORD dwInstallDir = sizeof(szInstallDir); + DWORD dwVersion = sizeof(szVersion); + LONG lRet; + + lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE, + "SOFTWARE\\Oracle\\VirtualBox", + 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, "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)); + } + } + + RegCloseKey( hKey ); + return 0; } @@ -1115,6 +1152,9 @@ 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_processor_info( p_vendor, sizeof(p_vendor), p_model, sizeof(p_model), diff --git a/lib/hostinfo.cpp b/lib/hostinfo.cpp index 67e6cdbfe2..572671bf13 100644 --- a/lib/hostinfo.cpp +++ b/lib/hostinfo.cpp @@ -68,6 +68,9 @@ void HOST_INFO::clear_host_info() { strcpy(os_name, ""); strcpy(os_version, ""); + strcpy(vm_name, ""); + strcpy(vm_version, ""); + coprocs.clear(); } @@ -109,6 +112,8 @@ 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 (match_tag(buf, "")) { coprocs.parse(in); } @@ -126,7 +131,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]; + char pv[265], pm[256], pf[256], osn[256], osv[256], vmn[256], vmv[256]; out.printf( "\n" " %d\n", @@ -145,6 +150,8 @@ 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" @@ -161,7 +168,9 @@ int HOST_INFO::write( " %f\n" " %f\n" " %s\n" - " %s\n", + " %s\n" + " %s\n" + " %s\n", host_cpid, p_ncpus, pv, @@ -177,7 +186,9 @@ int HOST_INFO::write( d_total, d_free, osn, - osv + osv, + vmn, + vmv ); if (include_coprocs) { coprocs.write_xml(out, false); diff --git a/lib/hostinfo.h b/lib/hostinfo.h index 44bbad4a57..ecf7e1b688 100644 --- a/lib/hostinfo.h +++ b/lib/hostinfo.h @@ -58,6 +58,9 @@ public: char os_name[256]; char os_version[256]; + char vm_name[256]; + char vm_version[256]; + COPROCS coprocs; HOST_INFO();