- 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.
This commit is contained in:
Rom Walton 2012-12-19 23:41:00 -05:00 committed by Oliver Bock
parent 58808d507e
commit 27557feae1
5 changed files with 62 additions and 13 deletions

View File

@ -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

View File

@ -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;

View File

@ -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();

View File

@ -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);

View File

@ -81,13 +81,13 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libcmt.lib libcpmt.lib kernel32.lib user32.lib gdi32.lib ole32.lib wsock32.lib psapi.lib"
OutputFile=".\Build\$(PlatformName)\$(ConfigurationName)\vboxwrapper_26012_windows_intelx86.exe"
OutputFile=".\Build\$(PlatformName)\$(ConfigurationName)\vboxwrapper_26013_windows_intelx86.exe"
LinkIncremental="0"
SuppressStartupBanner="true"
IgnoreAllDefaultLibraries="true"
DelayLoadDLLs=""
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Build\$(PlatformName)\$(ConfigurationName)\vboxwrapper_26012_windows_intelx86.pdb"
ProgramDatabaseFile=".\Build\$(PlatformName)\$(ConfigurationName)\vboxwrapper_26013_windows_intelx86.pdb"
SubSystem="2"
TargetMachine="1"
/>
@ -182,13 +182,13 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libcmt.lib libcpmt.lib kernel32.lib user32.lib gdi32.lib ole32.lib wsock32.lib psapi.lib"
OutputFile=".\Build\$(PlatformName)\$(ConfigurationName)\vboxwrapper_26012_windows_x86_64.exe"
OutputFile=".\Build\$(PlatformName)\$(ConfigurationName)\vboxwrapper_26013_windows_x86_64.exe"
LinkIncremental="0"
SuppressStartupBanner="true"
IgnoreAllDefaultLibraries="true"
DelayLoadDLLs=""
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Build\$(PlatformName)\$(ConfigurationName)\vboxwrapper_26012_windows_x86_64.pdb"
ProgramDatabaseFile=".\Build\$(PlatformName)\$(ConfigurationName)\vboxwrapper_26013_windows_x86_64.pdb"
SubSystem="2"
TargetMachine="17"
/>