VBOX: Rework VM running detection logic. We were checking for that condition in two places.

VBOX: Only attempt to unregister the VM on an unrecoverable startup error.
VBOX: Attempt to detect the VM process ID for all recoverable startup errors and report to BOINC.
This commit is contained in:
Rom Walton 2013-12-04 13:07:34 -05:00
parent 544c566dfe
commit 147638d295
2 changed files with 22 additions and 27 deletions

View File

@ -1004,7 +1004,8 @@ int VBOX_VM::run(double elapsed_time) {
// Check to see if the VM is already in a running state, if so, poweroff.
poll(false);
if (online) {
poweroff();
retval = poweroff();
if (retval) return ERR_NOT_EXITED;
}
// If our last checkpoint time is greater than 0, restore from the previously

View File

@ -656,10 +656,6 @@ int main(int argc, char** argv) {
char* temp_reason = (char*)"";
int temp_delay = 300;
// Attempt to cleanup the VM
vm.cleanup();
write_checkpoint(elapsed_time, vm);
fprintf(
stderr,
"%s VM failed to start.\n",
@ -704,23 +700,30 @@ int main(int argc, char** argv) {
);
unrecoverable_error = false;
temp_reason = (char*)"VM Hypervisor was unable to allocate enough memory to start VM.";
} else if (ERR_NOT_EXITED == retval) {
fprintf(
stderr,
"%s NOTE: VM was already running. BOINC will be notified that it needs to clean up the environment.\n"
" This might be a temporary problem and so this job will be rescheduled for another time.\n",
vboxwrapper_msg_prefix(buf, sizeof(buf))
);
unrecoverable_error = false;
temp_reason = (char*)"VM environment needed to be cleaned up.";
} else {
vm.poll();
vm.dumphypervisorlogs();
}
// Check to see if the VM is already running. If so, notify BOINC about the process ID so it can
if (unrecoverable_error) {
// Attempt to cleanup the VM and exit.
vm.cleanup();
write_checkpoint(elapsed_time, vm);
boinc_finish(retval);
} else {
// if the VM is already running notify BOINC about the process ID so it can
// clean up the environment. We should be safe to run after that.
//
if (vm.online) {
fprintf(
stderr,
"%s NOTE: VM was already running. BOINC will be notified that it needs to clean up the environment.\n"
" This might be a temporary problem and so this job will be rescheduled for another time.\n",
vboxwrapper_msg_prefix(buf, sizeof(buf))
);
unrecoverable_error = false;
temp_reason = (char*)"VM environment needed to be cleaned up.";
vm.get_vm_process_id(vm_pid);
vm.get_vm_process_id(vm_pid);
if (vm_pid) {
retval = boinc_report_app_status_aux(
elapsed_time,
checkpoint_cpu_time,
@ -729,16 +732,7 @@ int main(int argc, char** argv) {
bytes_sent,
bytes_received
);
} else {
vm.dumphypervisorlogs();
}
}
if (unrecoverable_error) {
boinc_finish(retval);
} else {
boinc_temporary_exit(temp_delay, temp_reason);
}
}