From b971791e5967b677697f685a8d4a0c3e5ed15b0e Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Mon, 3 Feb 2014 18:30:57 -0500 Subject: [PATCH] VBOX: If an error occurs, dump 8k of the VM trace log as well. Hopefully we can figure out what the duplicate UUID issue is as well as some of the snapshot issues. --- samples/vboxwrapper/vbox.cpp | 53 ++++++++++++++++++++++++++++++++++-- samples/vboxwrapper/vbox.h | 1 + 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp index a3242b1b90..b3557296a2 100644 --- a/samples/vboxwrapper/vbox.cpp +++ b/samples/vboxwrapper/vbox.cpp @@ -1444,6 +1444,7 @@ void VBOX_VM::dumphypervisorlogs(bool include_error_logs) { string local_system_log; string local_vm_log; string local_guest_log; + string local_trace_log; string prefiltered_guest_log; string filtered_guest_log; string line; @@ -1454,6 +1455,7 @@ void VBOX_VM::dumphypervisorlogs(bool include_error_logs) { get_system_log(local_system_log); get_vm_log(local_vm_log); + get_trace_log(local_trace_log); get_vm_log(prefiltered_guest_log, false); get_vm_exit_code(vm_exit_code); @@ -1499,14 +1501,18 @@ void VBOX_VM::dumphypervisorlogs(bool include_error_logs) { " Hypervisor System Log:\n\n" "%s\n" " VM Execution Log:\n\n" - "%s\n", + "%s\n" + " VM Trace Log:\n\n" + "%s", local_system_log.c_str(), - local_vm_log.c_str() + local_vm_log.c_str(), + local_trace_log.c_str() ); } fprintf( stderr, + "\n" " VM Guest Log:\n\n" "%s\n", local_guest_log.c_str() @@ -2089,6 +2095,49 @@ int VBOX_VM::get_vm_log(string& log, bool tail_only) { return retval; } +int VBOX_VM::get_trace_log(string& log, bool tail_only) { + string slot_directory; + string vm_trace_log; + string::iterator iter; + int retval = BOINC_SUCCESS; + + // Where should we copy temp files to? + get_slot_directory(slot_directory); + + // Locate and read log file + vm_trace_log = slot_directory + "/" + TRACELOG_FILENAME; + + if (boinc_file_exists(vm_trace_log.c_str())) { + if (tail_only) { + // Keep only the last 8k if it is larger than that. + read_file_string(vm_trace_log.c_str(), log, 8192, true); + } else { + read_file_string(vm_trace_log.c_str(), log); + } + + sanitize_output(log); + + if (tail_only) { + if (log.size() >= 8000) { + // 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); + } + } + } + + } else { + retval = ERR_NOT_FOUND; + } + + return retval; +} + // Enable the network adapter if a network connection is required. // NOTE: Network access should never be allowed if the code running in a // shared directory or the VM image itself is NOT signed. Doing so diff --git a/samples/vboxwrapper/vbox.h b/samples/vboxwrapper/vbox.h index 76de3fcd4a..92ee9da112 100644 --- a/samples/vboxwrapper/vbox.h +++ b/samples/vboxwrapper/vbox.h @@ -179,6 +179,7 @@ struct VBOX_VM { int get_system_log(std::string& log, bool tail_only = true); int get_vm_log(std::string& log, bool tail_only = true); + int get_trace_log(std::string& log, bool tail_only = true); int set_network_access(bool enabled); int set_cpu_usage(int percentage);