From 1432538891f8c1a04fefc062ca43065c195d8045 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Thu, 16 Apr 2015 18:48:38 -0400 Subject: [PATCH] VBOX: If is specified, automatically report completed checkpoints to the client as soon as the API requests them. --- samples/vboxwrapper/vboxwrapper.cpp | 31 ++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/samples/vboxwrapper/vboxwrapper.cpp b/samples/vboxwrapper/vboxwrapper.cpp index 72243c7aeb..b396949d44 100644 --- a/samples/vboxwrapper/vboxwrapper.cpp +++ b/samples/vboxwrapper/vboxwrapper.cpp @@ -369,6 +369,7 @@ int main(int argc, char** argv) { APP_INIT_DATA aid; VBOX_VM* pVM = NULL; VBOX_CHECKPOINT checkpoint; + double desired_checkpoint_interval = 0; double random_checkpoint_factor = 0; double elapsed_time = 0; double fraction_done = 0; @@ -496,6 +497,7 @@ int main(int argc, char** argv) { srand((int)(vm_image_stat.st_mtime * time(NULL))); } random_checkpoint_factor = (double)(((int)(drand() * 100000.0)) % 600); + vboxlog_msg("Feature: Checkpoint interval offset (%d seconds)", (int)random_checkpoint_factor); // Display trickle value if specified @@ -1035,10 +1037,17 @@ int main(int argc, char** argv) { pVM->dump_hypervisor_status_reports(); } + // Real VM checkpoints (snapshots) are expensive, don't do them very often. + // + // If the project has disabled automatic checkpoints, just report that we have + // successfully completed the checkpoint as soon as the API reports that we should + // checkpoint. + // if (boinc_time_to_checkpoint()) { - // Only peform a VM checkpoint every ten minutes or so. - // - if (elapsed_time >= last_checkpoint_elapsed_time + pVM->minimum_checkpoint_interval + random_checkpoint_factor) { + if ( + (elapsed_time >= last_checkpoint_elapsed_time + desired_checkpoint_interval + random_checkpoint_factor) || + pVM->disable_automatic_checkpoints + ) { // Basic interleave factor is only needed once. if (random_checkpoint_factor > 0) { random_checkpoint_factor = 0.0; @@ -1064,12 +1073,14 @@ int main(int argc, char** argv) { } } - // send elapsed-time trickle message if needed + // Send elapsed-time trickle message if needed // if (trickle_period) { check_trickle_period(elapsed_time, trickle_period); } + // Changes detected, re-read preferences + // if (boinc_status.reread_init_data_file) { boinc_status.reread_init_data_file = false; @@ -1079,7 +1090,17 @@ int main(int argc, char** argv) { boinc_get_init_data_p(&aid); set_throttles(aid, *pVM); - vboxlog_msg("Checkpoint Interval is now %d seconds.", (int)aid.checkpoint_period); + desired_checkpoint_interval = aid.checkpoint_period; + if (pVM->minimum_checkpoint_interval > aid.checkpoint_period) { + desired_checkpoint_interval = pVM->minimum_checkpoint_interval; + } + + vboxlog_msg( + "Setting checkpoint interval to %d seconds. (Higher value of (Preference: %d seconds) or (Vbox_job.xml: %d seconds))", + (int)desired_checkpoint_interval, + (int)aid.checkpoint_period, + (int)pVM->minimum_checkpoint_interval + ); } // if the VM has a maximum amount of time it is allowed to run,