From e1da8323bd9b0603760abacb9202263e52e873d4 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Wed, 24 Sep 2014 13:18:38 -0400 Subject: [PATCH] VBOX: Bubble up completion file notices to the client software. --- samples/vboxwrapper/vbox.cpp | 3 ++- samples/vboxwrapper/vboxwrapper.cpp | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp index ace42a8a1c..05003279a8 100644 --- a/samples/vboxwrapper/vbox.cpp +++ b/samples/vboxwrapper/vbox.cpp @@ -78,7 +78,8 @@ VBOX_VM::VBOX_VM() { vm_disk_controller_type.clear(); vm_disk_controller_model.clear(); os_name.clear(); - memory_size_mb.clear(); + vm_memory_size_mb.clear(); + memory_size_mb = 0.0; image_filename.clear(); iso_image_filename.clear(); cache_disk_filename.clear(); diff --git a/samples/vboxwrapper/vboxwrapper.cpp b/samples/vboxwrapper/vboxwrapper.cpp index 60cee6301c..e68c419c53 100644 --- a/samples/vboxwrapper/vboxwrapper.cpp +++ b/samples/vboxwrapper/vboxwrapper.cpp @@ -287,7 +287,7 @@ void read_fraction_done(double& frac_done, VBOX_VM& vm) { frac_done = frac; } -void read_completion_file_info(unsigned long& exit_code, string& message, VBOX_VM& vm) { +void read_completion_file_info(unsigned long& exit_code, bool& is_notice, string& message, VBOX_VM& vm) { char path[MAXPATHLEN]; char buf[1024]; @@ -300,6 +300,9 @@ void read_completion_file_info(unsigned long& exit_code, string& message, VBOX_V if (fgets(buf, 1024, f) != NULL) { exit_code = atoi(buf); } + if (fgets(buf, 1024, f) != NULL) { + is_notice = atoi(buf); + } while (fgets(buf, 1024, f) != NULL) { message += buf; } @@ -520,6 +523,7 @@ int main(int argc, char** argv) { double net_usage_timer = 600; int vm_image = 0; unsigned long vm_exit_code = 0; + bool is_notice = false; string message; char buf[256]; @@ -1079,8 +1083,19 @@ int main(int argc, char** argv) { "%s VM Completion File Detected.\n", vboxwrapper_msg_prefix(buf, sizeof(buf)) ); - read_completion_file_info(vm_exit_code, message, vm); - boinc_finish(vm_exit_code); + read_completion_file_info(vm_exit_code, is_notice, message, vm); + if (!is_notice && message.size()) { + fprintf( + stderr, + "%s VM Completion Message: %s.\n", + vboxwrapper_msg_prefix(buf, sizeof(buf)), + message.c_str() + ); + } else if (is_notice && message.size()) { + boinc_finish_message(vm_exit_code, message.c_str(), is_notice); + } else { + boinc_finish(vm_exit_code); + } } if (!vm.online) { // Is this a type of event we can recover from?