Commit fbb8e0dc authored by Rom Walton's avatar Rom Walton
Browse files

VBOX: Attempt to read VirtualBox logs in-place to cut down on disk I/O.

parent 30aca58f
......@@ -408,31 +408,19 @@ int VBOX_BASE::get_slot_directory(string& dir) {
}
int VBOX_BASE::get_system_log(string& log, bool tail_only, unsigned int buffer_size) {
string slot_directory;
string virtualbox_system_log_src;
string virtualbox_system_log_dst;
string virtualbox_system_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
virtualbox_system_log_src = virtualbox_home_directory + "/VBoxSVC.log";
virtualbox_system_log_dst = slot_directory + "/VBoxSVC.log";
if (boinc_file_exists(virtualbox_system_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_system_log_src.c_str(), virtualbox_system_log_dst.c_str());
}
virtualbox_system_log = virtualbox_home_directory + "/VBoxSVC.log";
if (boinc_file_exists(virtualbox_system_log_dst.c_str())) {
if (boinc_file_exists(virtualbox_system_log.c_str())) {
if (tail_only) {
// Keep only the last 8k if it is larger than that.
read_file_string(virtualbox_system_log_dst.c_str(), log, buffer_size, true);
read_file_string(virtualbox_system_log.c_str(), log, buffer_size, true);
} else {
read_file_string(virtualbox_system_log_dst.c_str(), log);
read_file_string(virtualbox_system_log.c_str(), log);
}
sanitize_output(log);
......@@ -456,31 +444,19 @@ int VBOX_BASE::get_system_log(string& log, bool tail_only, unsigned int buffer_s
}
int VBOX_BASE::get_vm_log(string& log, bool tail_only, unsigned int buffer_size) {
string slot_directory;
string virtualbox_vm_log_src;
string virtualbox_vm_log_dst;
string virtualbox_vm_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
virtualbox_vm_log_src = vm_master_name + "/Logs/VBox.log";
virtualbox_vm_log_dst = slot_directory + "/VBox.log";
if (boinc_file_exists(virtualbox_vm_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_vm_log_src.c_str(), virtualbox_vm_log_dst.c_str());
}
virtualbox_vm_log = vm_master_name + "/Logs/VBox.log";
if (boinc_file_exists(virtualbox_vm_log_dst.c_str())) {
if (boinc_file_exists(virtualbox_vm_log.c_str())) {
if (tail_only) {
// Keep only the last 8k if it is larger than that.
read_file_string(virtualbox_vm_log_dst.c_str(), log, buffer_size, true);
read_file_string(virtualbox_vm_log.c_str(), log, buffer_size, true);
} else {
read_file_string(virtualbox_vm_log_dst.c_str(), log);
read_file_string(virtualbox_vm_log.c_str(), log);
}
sanitize_output(log);
......@@ -505,16 +481,12 @@ int VBOX_BASE::get_vm_log(string& log, bool tail_only, unsigned int buffer_size)
}
int VBOX_BASE::get_trace_log(string& log, bool tail_only, unsigned int buffer_size) {
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;
vm_trace_log = TRACELOG_FILENAME;
if (boinc_file_exists(vm_trace_log.c_str())) {
if (tail_only) {
......@@ -548,31 +520,19 @@ int VBOX_BASE::get_trace_log(string& log, bool tail_only, unsigned int buffer_si
}
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 virtualbox_startup_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
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());
}
virtualbox_startup_log = vm_master_name + "/Logs/VBoxStartup.log";
if (boinc_file_exists(virtualbox_startup_log_dst.c_str())) {
if (boinc_file_exists(virtualbox_startup_log.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);
read_file_string(virtualbox_startup_log.c_str(), log, buffer_size, true);
} else {
read_file_string(virtualbox_startup_log_dst.c_str(), log);
read_file_string(virtualbox_startup_log.c_str(), log);
}
sanitize_output(log);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment