VBOX: If polling for the current VM state fails for any reason, like vboxsvc crashing, do a temp exit for 24 hours.

Before COM, polling for the current state wasn't as critical.  If the poll operation failed, we would try again in one second anyway.

After COM, it is used as a test to see if the communication channel between the wrapper and VirtualBox is still operational.  If not, temp exit and hope things work the next attempt.
This commit is contained in:
Rom Walton 2015-03-27 16:34:09 -04:00
parent cb573ef75f
commit 3a399ea0f5
6 changed files with 22 additions and 7 deletions

View File

@ -168,7 +168,7 @@ public:
virtual int register_vm() = 0;
virtual int deregister_vm(bool delete_media) = 0;
virtual int deregister_stale_vm() = 0;
virtual void poll(bool log_state = true) = 0;
virtual int poll(bool log_state = true) = 0;
virtual int start() = 0;
virtual int stop() = 0;
virtual int poweroff() = 0;

View File

@ -1155,7 +1155,8 @@ int VBOX_VM::deregister_stale_vm() {
return 0;
}
void VBOX_VM::poll(bool log_state) {
int VBOX_VM::poll(bool log_state) {
int retval = ERR_EXEC;
APP_INIT_DATA aid;
HRESULT rc;
CComPtr<IMachine> pMachine;
@ -1181,7 +1182,6 @@ void VBOX_VM::poll(bool log_state) {
if (SUCCEEDED(rc) && pMachine) {
rc = pMachine->get_State(&vmstate);
if (SUCCEEDED(rc)) {
// VirtualBox Documentation suggests that that a VM is running when its
// machine state is between MachineState_FirstOnline and MachineState_LastOnline
// which as of this writing is 5 and 17.
@ -1289,6 +1289,8 @@ void VBOX_VM::poll(bool log_state) {
);
vmstate_old = vmstate;
}
retval = BOINC_SUCCESS;
}
}
@ -1304,6 +1306,8 @@ void VBOX_VM::poll(bool log_state) {
// Dump any new VM Guest Log entries
//
dump_vmguestlog_entries();
return retval;
}
int VBOX_VM::start() {

View File

@ -27,7 +27,7 @@ public:
int register_vm();
int deregister_vm(bool delete_media);
int deregister_stale_vm();
void poll(bool log_state = true);
int poll(bool log_state = true);
int start();
int stop();
int poweroff();

View File

@ -824,7 +824,8 @@ int VBOX_VM::deregister_stale_vm() {
return 0;
}
void VBOX_VM::poll(bool log_state) {
int VBOX_VM::poll(bool log_state) {
int retval = ERR_EXEC;
APP_INIT_DATA aid;
string command;
string output;
@ -955,6 +956,8 @@ void VBOX_VM::poll(bool log_state) {
vboxlog_msg("VM state change detected. (old = '%s', new = '%s')", vmstate_old.c_str(), vmstate.c_str());
vmstate_old = vmstate;
}
retval = BOINC_SUCCESS;
}
}
@ -970,6 +973,8 @@ void VBOX_VM::poll(bool log_state) {
// Dump any new VM Guest Log entries
//
dump_vmguestlog_entries();
return retval;
}
int VBOX_VM::start() {

View File

@ -33,7 +33,7 @@ namespace vboxmanage {
int register_vm();
int deregister_vm(bool delete_media);
int deregister_stale_vm();
void poll(bool log_state = true);
int poll(bool log_state = true);
int start();
int stop();
int poweroff();

View File

@ -867,7 +867,13 @@ int main(int argc, char** argv) {
loop_iteration += 1;
// Discover the VM's current state
pVM->poll();
retval = pVM->poll();
if (retval) {
vboxlog_msg("ERROR: Vboxwrapper lost communication with VirtualBox, rescheduling task for a later time.");
pVM->reset_vm_process_priority();
pVM->poweroff();
boinc_temporary_exit(86400, "VM job unmanageable, restarting later.");
}
// Write updates for the graphics application's use
if (pVM->enable_graphics_support) {