VBOX: Add VboxStartup.log to the list of partial log dumps to stderr when something goes wrong.

This commit is contained in:
Rom Walton 2015-04-08 12:52:59 -04:00
parent 8e4ad3d999
commit 19b3dd982b
2 changed files with 70 additions and 1 deletions

View File

@ -217,15 +217,34 @@ void VBOX_BASE::cleanup() {
void VBOX_BASE::dump_hypervisor_logs(bool include_error_logs) {
string local_system_log;
string local_vm_log;
string local_startup_log;
string local_trace_log;
unsigned long vm_exit_code = 0;
get_system_log(local_system_log);
get_vm_log(local_vm_log);
get_trace_log(local_trace_log);
get_trace_log(local_startup_log);
get_vm_exit_code(vm_exit_code);
if (include_error_logs) {
if (include_error_logs && !started_successfully) {
fprintf(
stderr,
"\n"
" Hypervisor System Log:\n\n"
"%s\n"
" VM Execution Log:\n\n"
"%s\n"
" VM Startup Log:\n\n"
"%s\n"
" VM Trace Log:\n\n"
"%s",
local_system_log.c_str(),
local_vm_log.c_str(),
local_startup_log.c_str(),
local_trace_log.c_str()
);
} else {
fprintf(
stderr,
"\n"
@ -512,6 +531,55 @@ int VBOX_BASE::get_trace_log(string& log, bool tail_only, unsigned int buffer_si
return retval;
}
int VBOX_BASE::get_startup_log(string& log, bool tail_only, unsigned int buffer_size) {
string slot_directory;
string virtualbox_startup_log_src;
string virtualbox_startup_log_dst;
string::iterator iter;
int retval = BOINC_SUCCESS;
// Where should we copy temp files to?
get_slot_directory(slot_directory);
// Locate and read log file
virtualbox_startup_log_src = vm_master_name + "/Logs/VBoxStartup.log";
virtualbox_startup_log_dst = slot_directory + "/VBoxStartup.log";
if (boinc_file_exists(virtualbox_startup_log_src.c_str())) {
// Skip having to deal with various forms of file locks by just making a temp
// copy of the log file.
boinc_copy(virtualbox_startup_log_src.c_str(), virtualbox_startup_log_dst.c_str());
}
if (boinc_file_exists(virtualbox_startup_log_dst.c_str())) {
if (tail_only) {
// Keep only the last 8k if it is larger than that.
read_file_string(virtualbox_startup_log_dst.c_str(), log, buffer_size, true);
} else {
read_file_string(virtualbox_startup_log_dst.c_str(), log);
}
sanitize_output(log);
if (tail_only) {
if (log.size() >= (buffer_size - 115)) {
// Look for the next whole line of text.
iter = log.begin();
while (iter != log.end()) {
if (*iter == '\n') {
log.erase(iter);
break;
}
iter = log.erase(iter);
}
}
}
}
return retval;
}
int VBOX_BASE::read_floppy(std::string& data) {
if (enable_floppyio && pFloppy) {
data = pFloppy->receive();

View File

@ -214,6 +214,7 @@ public:
virtual int get_system_log(std::string& log, bool tail_only = true, unsigned int buffer_size = 8192);
virtual int get_vm_log(std::string& log, bool tail_only = true, unsigned int buffer_size = 8192);
virtual int get_trace_log(std::string& log, bool tail_only = true, unsigned int buffer_size = 8192);
virtual int get_startup_log(std::string& log, bool tail_only = true, unsigned int buffer_size = 8192);
virtual int set_network_access(bool enabled) = 0;
virtual int set_cpu_usage(int percentage) = 0;