diff --git a/samples/vboxwrapper/vboxwrapper.cpp b/samples/vboxwrapper/vboxwrapper.cpp index 532ba27db0..3b6fa33bda 100644 --- a/samples/vboxwrapper/vboxwrapper.cpp +++ b/samples/vboxwrapper/vboxwrapper.cpp @@ -771,35 +771,6 @@ int main(int argc, char** argv) { " This might be a temporary problem and so this job will be rescheduled for another time.\n"; unrecoverable_error = false; temp_reason = "VM environment needed to be cleaned up."; - } else if (pVM->is_logged_failure_vm_extensions_disabled()) { - error_reason = - " NOTE: BOINC has detected that your computer's processor supports hardware acceleration for\n" - " virtual machines but the hypervisor failed to successfully launch with this feature enabled.\n" - " This means that the hardware acceleration feature has been disabled in the computer's BIOS.\n" - " Please enable this feature in your computer's BIOS.\n" - " Intel calls it 'VT-x'\n" - " AMD calls it 'AMD-V'\n" - " More information can be found here: http://en.wikipedia.org/wiki/X86_virtualization\n" - " Error Code: ERR_CPU_VM_EXTENSIONS_DISABLED\n"; - retval = ERR_EXEC; - } else if (pVM->is_logged_failure_vm_extensions_not_supported()) { - error_reason = - " NOTE: VirtualBox has reported an improperly configured virtual machine. It was configured to require\n" - " hardware acceleration for virtual machines, but your processor does not support the required feature.\n" - " Please report this issue to the project so that it can be addresssed.\n"; - } else if (pVM->is_logged_failure_vm_extensions_in_use()) { - error_reason = - " NOTE: VirtualBox hypervisor reports that another hypervisor has locked the hardware acceleration\n" - " for virtual machines feature in exclusive mode.\n"; - unrecoverable_error = false; - temp_reason = "Forign VM Hypervisor locked hardware acceleration features."; - temp_delay = 86400; - } else if (pVM->is_logged_failure_host_out_of_memory()) { - error_reason = - " NOTE: VirtualBox has failed to allocate enough memory to start the configured virtual machine.\n" - " This might be a temporary problem and so this job will be rescheduled for another time.\n"; - unrecoverable_error = false; - temp_reason = "VM Hypervisor was unable to allocate enough memory to start VM."; } else { do_dump_hypervisor_logs = true; } @@ -882,16 +853,99 @@ int main(int argc, char** argv) { // Log our current state pVM->poll(true); - // Did we timeout? - if (!pVM->online && (timeout <= dtime())) { - vboxlog_msg("NOTE: VM failed to enter an online state within the timeout period."); - vboxlog_msg(" This might be a temporary problem and so this job will be rescheduled for another time."); - pVM->reset_vm_process_priority(); - pVM->poweroff(); - pVM->dump_hypervisor_logs(true); - boinc_temporary_exit(86400, - "VM Hypervisor failed to enter an online state in a timely fashion." - ); + // Is the VM still running? If not, why not? + // + if (!pVM->online) { + // All 'failure to start' errors are unrecoverable by default + bool unrecoverable_error = true; + bool skip_cleanup = false; + bool do_dump_hypervisor_logs = false; + string error_reason; + const char* temp_reason = ""; + + if (pVM->is_logged_failure_vm_extensions_disabled()) { + error_reason = + " NOTE: BOINC has detected that your computer's processor supports hardware acceleration for\n" + " virtual machines but the hypervisor failed to successfully launch with this feature enabled.\n" + " This means that the hardware acceleration feature has been disabled in the computer's BIOS.\n" + " Please enable this feature in your computer's BIOS.\n" + " Intel calls it 'VT-x'\n" + " AMD calls it 'AMD-V'\n" + " More information can be found here: http://en.wikipedia.org/wiki/X86_virtualization\n" + " Error Code: ERR_CPU_VM_EXTENSIONS_DISABLED\n"; + retval = ERR_EXEC; + } else if (pVM->is_logged_failure_vm_extensions_not_supported()) { + error_reason = + " NOTE: VirtualBox has reported an improperly configured virtual machine. It was configured to require\n" + " hardware acceleration for virtual machines, but your processor does not support the required feature.\n" + " Please report this issue to the project so that it can be addresssed.\n"; + } else if (pVM->is_logged_failure_vm_extensions_in_use()) { + error_reason = + " NOTE: VirtualBox hypervisor reports that another hypervisor has locked the hardware acceleration\n" + " for virtual machines feature in exclusive mode.\n"; + unrecoverable_error = false; + temp_reason = "Forign VM Hypervisor locked hardware acceleration features."; + temp_delay = 86400; + } else if (pVM->is_logged_failure_host_out_of_memory()) { + error_reason = + " NOTE: VirtualBox has failed to allocate enough memory to start the configured virtual machine.\n" + " This might be a temporary problem and so this job will be rescheduled for another time.\n"; + unrecoverable_error = false; + temp_reason = "VM Hypervisor was unable to allocate enough memory to start VM."; + } else if (timeout <= dtime()) { + error_reason = + " NOTE: VM failed to enter an online state within the timeout period.\n" + " This might be a temporary problem and so this job will be rescheduled for another time.\n"; + unrecoverable_error = false; + do_dump_hypervisor_logs = true; + temp_reason = "VM Hypervisor failed to enter an online state in a timely fashion."; + temp_delay = 86400; + } + + if (unrecoverable_error) { + // Attempt to cleanup the VM and exit. + if (!skip_cleanup) { + pVM->cleanup(); + } + + checkpoint.update(elapsed_time, current_cpu_time); + + if (error_reason.size()) { + vboxlog_msg("\n%s", error_reason.c_str()); + } + + if (do_dump_hypervisor_logs) { + pVM->dump_hypervisor_logs(true); + } + + 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 (pVM->vm_pid) { + retval = boinc_report_app_status_aux( + current_cpu_time, + last_checkpoint_cpu_time, + fraction_done, + pVM->vm_pid, + bytes_sent, + bytes_received + ); + } + + // Give the BOINC API time to report the pid to BOINC. + // + boinc_sleep(5.0); + + if (error_reason.size()) { + vboxlog_msg("\n%s", error_reason.c_str()); + } + + // Exit and let BOINC clean up the rest. + // + boinc_temporary_exit(temp_delay, temp_reason); + } } set_floppy_image(aid, *pVM);