From 25142dda02ccdcf0404d51e6974cd9d33102399a Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Fri, 16 Mar 2012 01:04:43 +0000 Subject: [PATCH] - VBOX: Give the VM process a short priority boost when responding to a quit request. On older XP machines it might speed up the memory dump to disk. - client: Increase the quit request timeout from 10 seconds to 60 seconds for machines running VMs and slow disk drives. It should give the VM enough time to gracefully shutdown and not give boinc reason to kill the wrapper. client/ app.h samples/vboxwrapper/ vbox.cpp, .h vboxwrapper.cpp svn path=/trunk/boinc/; revision=25433 --- checkin_notes | 14 ++++++++++++++ client/app.h | 4 ++-- samples/vboxwrapper/vbox.cpp | 14 +++++++++++++- samples/vboxwrapper/vbox.h | 1 + samples/vboxwrapper/vboxwrapper.cpp | 13 ++----------- win_build/vboxwrapper.vcproj | 8 ++++---- 6 files changed, 36 insertions(+), 18 deletions(-) diff --git a/checkin_notes b/checkin_notes index f5bb869052..c657a4e284 100644 --- a/checkin_notes +++ b/checkin_notes @@ -2701,3 +2701,17 @@ David 15 Mar 2012 sched_config.cpp,h feeder.cpp hr_info.cpp + +Rom 15 Mar 2012 + - VBOX: Give the VM process a short priority boost when responding + to a quit request. On older XP machines it might speed up the memory + dump to disk. + - client: Increase the quit request timeout from 10 seconds to 60 seconds for + machines running VMs and slow disk drives. It should give the VM enough + time to gracefully shutdown and not give boinc reason to kill the wrapper. + + client/ + app.h + samples/vboxwrapper/ + vbox.cpp, .h + vboxwrapper.cpp diff --git a/client/app.h b/client/app.h index 2b9d95b865..9519ef879e 100644 --- a/client/app.h +++ b/client/app.h @@ -32,8 +32,8 @@ // if we send app request, wait this long before killing it. // This gives it time to download symbol files (which can be several MB) // and write stack trace to stderr -#define QUIT_TIMEOUT 10 - // Same, for . Shorter because no stack trace is generated +#define QUIT_TIMEOUT 60 + // Same, for . // values for preempt_type // diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp index 296e86a907..dab1c683b3 100644 --- a/samples/vboxwrapper/vbox.cpp +++ b/samples/vboxwrapper/vbox.cpp @@ -1307,7 +1307,7 @@ int VBOX_VM::write_floppy(std::string& data) { return 1; } -void VBOX_VM::reset_vm_process_priority() { +void VBOX_VM::lower_vm_process_priority() { #ifndef _WIN32 if (vm_pid) { setpriority(PRIO_PROCESS, vm_pid, PROCESS_IDLE_PRIORITY); @@ -1319,6 +1319,18 @@ void VBOX_VM::reset_vm_process_priority() { #endif } +void VBOX_VM::reset_vm_process_priority() { +#ifndef _WIN32 + if (vm_pid) { + setpriority(PRIO_PROCESS, vm_pid, PROCESS_MEDIUM_PRIORITY); + } +#else + if (vm_pid_handle) { + SetPriorityClass(vm_pid_handle, NORMAL_PRIORITY_CLASS); + } +#endif +} + // If there are errors we can recover from, process them here. // int VBOX_VM::vbm_popen(string& arguments, string& output, const char* item, bool log_error, bool retry_failures) { diff --git a/samples/vboxwrapper/vbox.h b/samples/vboxwrapper/vbox.h index 32b633505d..5972adb591 100644 --- a/samples/vboxwrapper/vbox.h +++ b/samples/vboxwrapper/vbox.h @@ -126,6 +126,7 @@ struct VBOX_VM { int read_floppy(std::string& data); int write_floppy(std::string& data); + void lower_vm_process_priority(); void reset_vm_process_priority(); int vbm_popen( diff --git a/samples/vboxwrapper/vboxwrapper.cpp b/samples/vboxwrapper/vboxwrapper.cpp index 3df28ef89b..953ad7c354 100644 --- a/samples/vboxwrapper/vboxwrapper.cpp +++ b/samples/vboxwrapper/vboxwrapper.cpp @@ -540,6 +540,7 @@ int main(int argc, char** argv) { vm.poll(); if (boinc_status.no_heartbeat || boinc_status.quit_request) { + vm.reset_vm_process_priority(); vm.stop(); write_checkpoint(checkpoint_cpu_time, vm); boinc_temporary_exit(0); @@ -589,20 +590,10 @@ int main(int argc, char** argv) { } if (boinc_status.suspended) { if (!vm.suspended) { - fprintf( - stderr, - "%s Suspending VM.\n", - vboxwrapper_msg_prefix(buf, sizeof(buf)) - ); vm.pause(); } } else { if (vm.suspended) { - fprintf( - stderr, - "%s Resuming VM.\n", - vboxwrapper_msg_prefix(buf, sizeof(buf)) - ); vm.resume(); } @@ -611,7 +602,7 @@ int main(int argc, char** argv) { if (!vm_pid) { vm.get_vm_process_id(vm_pid); if (vm_pid) { - vm.reset_vm_process_priority(); + vm.lower_vm_process_priority(); report_vm_pid = true; } } diff --git a/win_build/vboxwrapper.vcproj b/win_build/vboxwrapper.vcproj index 338e656c33..9b02628d46 100644 --- a/win_build/vboxwrapper.vcproj +++ b/win_build/vboxwrapper.vcproj @@ -81,13 +81,13 @@ @@ -182,13 +182,13 @@