From c768866118b6137e76da6d72923aca925fe0b56a Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Mon, 15 Sep 2014 17:21:11 -0400 Subject: [PATCH] VBOX: Look for the fraction done file in the shared directory by default --- samples/vboxwrapper/vboxwrapper.cpp | 46 +++++++++++++++-------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/samples/vboxwrapper/vboxwrapper.cpp b/samples/vboxwrapper/vboxwrapper.cpp index e05fc696f5..3f82e2cbdb 100644 --- a/samples/vboxwrapper/vboxwrapper.cpp +++ b/samples/vboxwrapper/vboxwrapper.cpp @@ -258,10 +258,12 @@ void read_checkpoint(double& elapsed, double& cpu, VBOX_VM& vm) { } void read_fraction_done(double& frac_done, VBOX_VM& vm) { + char path[MAXPATHLEN]; char buf[256]; double temp, frac = 0; - FILE* f = fopen(vm.fraction_done_filename.c_str(), "r"); + sprintf(path, "shared/%s", vm.fraction_done_filename.c_str()); + FILE* f = fopen(path, "r"); if (!f) return; // read the last line of the file @@ -285,6 +287,26 @@ 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) { + char path[MAXPATHLEN]; + char buf[1024]; + + exit_code = 0; + message = ""; + + sprintf(path, "shared/%s", vm.completion_trigger_file.c_str()); + FILE* f = fopen(path, "r"); + if (f) { + if (fgets(buf, 1024, f) != NULL) { + exit_code = atoi(buf); + } + while (fgets(buf, 1024, f) != NULL) { + message += buf; + } + fclose(f); + } +} + // set CPU and network throttling if needed // void set_throttles(APP_INIT_DATA& aid, VBOX_VM& vm) { @@ -407,26 +429,6 @@ void set_remote_desktop_info(APP_INIT_DATA& /* aid */, VBOX_VM& vm) { } } -void extract_completion_file_info(VBOX_VM& vm, unsigned long& exit_code, string& message) { - char path[MAXPATHLEN]; - char buf[1024]; - - exit_code = 0; - message = ""; - - sprintf(path, "shared/%s", vm.completion_trigger_file.c_str()); - FILE* f = fopen(path, "r"); - if (f) { - if (fgets(buf, 1024, f) != NULL) { - exit_code = atoi(buf); - } - while (fgets(buf, 1024, f) != NULL) { - message += buf; - } - fclose(f); - } -} - // check for trickle trigger files, and send trickles if find them. // void VBOX_VM::check_trickle_triggers() { @@ -1066,7 +1068,7 @@ int main(int argc, char** argv) { "%s VM Completion File Detected.\n", vboxwrapper_msg_prefix(buf, sizeof(buf)) ); - extract_completion_file_info(vm, vm_exit_code, message); + read_completion_file_info(vm_exit_code, message, vm); boinc_finish(vm_exit_code); } if (!vm.online) {