VBOX: Bubble up completion file notices to the client software.

This commit is contained in:
Rom Walton 2014-09-24 13:18:38 -04:00
parent 99c8c678dd
commit e1da8323bd
2 changed files with 20 additions and 4 deletions

View File

@ -78,7 +78,8 @@ VBOX_VM::VBOX_VM() {
vm_disk_controller_type.clear(); vm_disk_controller_type.clear();
vm_disk_controller_model.clear(); vm_disk_controller_model.clear();
os_name.clear(); os_name.clear();
memory_size_mb.clear(); vm_memory_size_mb.clear();
memory_size_mb = 0.0;
image_filename.clear(); image_filename.clear();
iso_image_filename.clear(); iso_image_filename.clear();
cache_disk_filename.clear(); cache_disk_filename.clear();

View File

@ -287,7 +287,7 @@ void read_fraction_done(double& frac_done, VBOX_VM& vm) {
frac_done = frac; 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 path[MAXPATHLEN];
char buf[1024]; 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) { if (fgets(buf, 1024, f) != NULL) {
exit_code = atoi(buf); exit_code = atoi(buf);
} }
if (fgets(buf, 1024, f) != NULL) {
is_notice = atoi(buf);
}
while (fgets(buf, 1024, f) != NULL) { while (fgets(buf, 1024, f) != NULL) {
message += buf; message += buf;
} }
@ -520,6 +523,7 @@ int main(int argc, char** argv) {
double net_usage_timer = 600; double net_usage_timer = 600;
int vm_image = 0; int vm_image = 0;
unsigned long vm_exit_code = 0; unsigned long vm_exit_code = 0;
bool is_notice = false;
string message; string message;
char buf[256]; char buf[256];
@ -1079,9 +1083,20 @@ int main(int argc, char** argv) {
"%s VM Completion File Detected.\n", "%s VM Completion File Detected.\n",
vboxwrapper_msg_prefix(buf, sizeof(buf)) vboxwrapper_msg_prefix(buf, sizeof(buf))
); );
read_completion_file_info(vm_exit_code, message, vm); 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); boinc_finish(vm_exit_code);
} }
}
if (!vm.online) { if (!vm.online) {
// Is this a type of event we can recover from? // Is this a type of event we can recover from?
if (vm.is_logged_failure_host_out_of_memory()) { if (vm.is_logged_failure_host_out_of_memory()) {