From 557581595342d82abeb4956d5617a14f7fa78286 Mon Sep 17 00:00:00 2001 From: computezrmle <57127745+computezrmle@users.noreply.github.com> Date: Thu, 13 Jan 2022 12:42:52 +0100 Subject: [PATCH 01/11] Introduce tag Required in connection with feature request #4602 --- samples/vboxwrapper/vboxjob.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/vboxwrapper/vboxjob.cpp b/samples/vboxwrapper/vboxjob.cpp index 73c7e0738f4..c1013aea37c 100644 --- a/samples/vboxwrapper/vboxjob.cpp +++ b/samples/vboxwrapper/vboxjob.cpp @@ -109,6 +109,7 @@ void VBOX_JOB::clear() { heartbeat_filename.clear(); completion_trigger_file.clear(); temporary_exit_trigger_file.clear(); + multiattach_vdi_file.clear(); enable_cern_dataformat = false; enable_shared_directory = false; enable_scratch_directory = false; @@ -170,6 +171,7 @@ int VBOX_JOB::parse() { else if (xp.parse_string("heartbeat_filename", heartbeat_filename)) continue; else if (xp.parse_string("completion_trigger_file", completion_trigger_file)) continue; else if (xp.parse_string("temporary_exit_trigger_file", temporary_exit_trigger_file)) continue; + else if (xp.parse_string("multiattach_vdi_file", multiattach_vdi_file)) continue; else if (xp.parse_bool("enable_cern_dataformat", enable_cern_dataformat)) continue; else if (xp.parse_bool("enable_network", enable_network)) continue; else if (xp.parse_bool("network_bridged_mode", network_bridged_mode)) continue; From 03b93fe2872ae316611fbed588e4e3d49d49c888 Mon Sep 17 00:00:00 2001 From: computezrmle <57127745+computezrmle@users.noreply.github.com> Date: Thu, 13 Jan 2022 12:43:10 +0100 Subject: [PATCH 02/11] Introduce tag Required in connection with feature request #4602 --- samples/vboxwrapper/vboxjob.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/vboxwrapper/vboxjob.h b/samples/vboxwrapper/vboxjob.h index 3a4627b4971..d189685f803 100644 --- a/samples/vboxwrapper/vboxjob.h +++ b/samples/vboxwrapper/vboxjob.h @@ -166,6 +166,10 @@ class VBOX_JOB { // File can optionally contain is_notice bool (second line) // and stderr text (subsequent lines). // Addresses a problem where VM doesn't shut down properly + + std::string multiattach_vdi_file; + // Name of the vdi file (without path) to be attached in multiattach mode. + // The file is expected to be in the project's base directory. }; #endif From 42d5d87fb3efe27a675121d09f2ac3e3743de5e5 Mon Sep 17 00:00:00 2001 From: computezrmle <57127745+computezrmle@users.noreply.github.com> Date: Thu, 13 Jan 2022 12:43:19 +0100 Subject: [PATCH 03/11] Add code to use VirtualBox differencing images Required in connection with feature request #4602 --- samples/vboxwrapper/vbox_vboxmanage.cpp | 74 +++++++++++++++++++++---- 1 file changed, 64 insertions(+), 10 deletions(-) diff --git a/samples/vboxwrapper/vbox_vboxmanage.cpp b/samples/vboxwrapper/vbox_vboxmanage.cpp index dbf99abc32a..2b83fe6addb 100644 --- a/samples/vboxwrapper/vbox_vboxmanage.cpp +++ b/samples/vboxwrapper/vbox_vboxmanage.cpp @@ -500,18 +500,72 @@ namespace vboxmanage { // Adding virtual hard drive to VM // - vboxlog_msg("Adding virtual disk drive to VM. (%s)", image_filename.c_str()); + string command_fix_part; + + command_fix_part = "storageattach \"" + vm_name + "\" "; + command_fix_part += "--storagectl \"Hard Disk Controller\" "; + command_fix_part += "--port 0 "; + command_fix_part += "--device 0 "; + command_fix_part += "--type hdd "; + + if (!multiattach_vdi_file.size()) { + // the traditional method: + // copy the vdi file from the projects dir to the slots dir and rename it vm_image.vdi + // each copy must get a new (random) UUID + // + vboxlog_msg("Adding virtual disk drive to VM. (%s)", image_filename.c_str()); + command = command_fix_part; + command += "--setuuid \"\" "; + command += "--medium \"" + virtual_machine_slot_directory + "/" + image_filename + "\" "; - command = "storageattach \"" + vm_name + "\" "; - command += "--storagectl \"Hard Disk Controller\" "; - command += "--port 0 "; - command += "--device 0 "; - command += "--type hdd "; - command += "--setuuid \"\" "; - command += "--medium \"" + virtual_machine_slot_directory + "/" + image_filename + "\" "; + retval = vbm_popen(command, output, "storage attach (fixed disk)"); + if (retval) return retval; + } else { + // Use MultiAttach mode and differencing images + // See: https://www.virtualbox.org/manual/ch05.html#hdimagewrites + // https://www.virtualbox.org/manual/ch05.html#diffimages + // the vdi file downloaded to the projects dir becomes the parent (read only) + // "--setuid" must not be used + // each task gets it's own differencing image (writable) + // differencing images are written to the VM's snapshot folder + // + string medium_file = aid.project_dir; + medium_file += "/" + multiattach_vdi_file; + + vboxlog_msg("Adding virtual disk drive to VM. (%s)", multiattach_vdi_file.c_str()); + command = "list hdds"; + + retval = vbm_popen(command, output, "check if parent hdd is registered", false, false); + if (retval) return retval; + + if (output.find(medium_file) == string::npos) { + // parent hdd is not registered + // vdi files can't be registered and set to multiattach mode within 1 step. + // They must first be attached to a VM in normal mode, then detached from the VM + // + command = command_fix_part; + command += "--medium \"" + medium_file + "\" "; + + retval = vbm_popen(command, output, "register parent hdd", false, false); + if (retval) return retval; + + command = command_fix_part; + command += "--medium none "; + + retval = vbm_popen(command, output, "detach parent vdi", false, false); + if (retval) return retval; + // the vdi file is now registered and ready to be attached in multiattach mode + // + } + + command = command_fix_part; + command += "--mtype multiattach "; + command += "--medium \"" + medium_file + "\" "; + + retval = vbm_popen(command, output, "storage attach (fixed disk - multiattach mode)"); + if (retval) return retval; + } - retval = vbm_popen(command, output, "storage attach (fixed disk)"); - if (retval) return retval; // Add guest additions to the VM // From 88cbbbe29b18ae9fd00c20322dd9ef328251e6a4 Mon Sep 17 00:00:00 2001 From: computezrmle <57127745+computezrmle@users.noreply.github.com> Date: Mon, 17 Jan 2022 07:16:07 +0100 Subject: [PATCH 04/11] Update vbox_vboxmanage.cpp Output from "vboxmanage -q list hdds" contains paths that are compared with the path of a file. Linux uses "/" as preferred directory separator while Windows uses "\". This patch ensures the compare delivers the same result on both platforms. --- samples/vboxwrapper/vbox_vboxmanage.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/samples/vboxwrapper/vbox_vboxmanage.cpp b/samples/vboxwrapper/vbox_vboxmanage.cpp index 2b83fe6addb..1580b1f43db 100644 --- a/samples/vboxwrapper/vbox_vboxmanage.cpp +++ b/samples/vboxwrapper/vbox_vboxmanage.cpp @@ -16,6 +16,7 @@ // along with BOINC. If not, see . #ifdef _WIN32 +#include #include "boinc_win.h" #include "win_util.h" #else @@ -532,12 +533,20 @@ namespace vboxmanage { string medium_file = aid.project_dir; medium_file += "/" + multiattach_vdi_file; +#ifdef _WIN32 + replace(medium_file.begin(), medium_file.end(), '\\', '/'); +#endif + vboxlog_msg("Adding virtual disk drive to VM. (%s)", multiattach_vdi_file.c_str()); command = "list hdds"; retval = vbm_popen(command, output, "check if parent hdd is registered", false, false); if (retval) return retval; +#ifdef _WIN32 + replace(output.begin(), output.end(), '\\', '/'); +#endif + if (output.find(medium_file) == string::npos) { // parent hdd is not registered // vdi files can't be registered and set to multiattach mode within 1 step. From 8383cc5015656cde5293180744122d9b52f684c0 Mon Sep 17 00:00:00 2001 From: computezrmle <57127745+computezrmle@users.noreply.github.com> Date: Wed, 19 Jan 2022 20:33:01 +0100 Subject: [PATCH 05/11] Update dhrystone.cpp --- client/dhrystone.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/dhrystone.cpp b/client/dhrystone.cpp index 3346ae6191a..1370f960106 100644 --- a/client/dhrystone.cpp +++ b/client/dhrystone.cpp @@ -90,7 +90,7 @@ int dhrystone( unsigned long Loops; DS_DATA dd; - double startclock, endclock; + double startclock = 0.0, endclock = 0.0; double benchtime; double Dhrystones_Per_Second; From 138867fd9a69042e0359a11589b81c62f32483ee Mon Sep 17 00:00:00 2001 From: computezrmle <57127745+computezrmle@users.noreply.github.com> Date: Wed, 19 Jan 2022 20:34:23 +0100 Subject: [PATCH 06/11] Update dhrystone.h --- client/dhrystone.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/dhrystone.h b/client/dhrystone.h index 60a298994d9..6200c988045 100644 --- a/client/dhrystone.h +++ b/client/dhrystone.h @@ -1,5 +1,6 @@ -#ifdef __APPLE__ +#if defined __APPLE__ || __cplusplus >= 201703L +//#if defined __APPLE__ || __cplusplus >= 202002L #define REG #else #define REG register From 0688a166cbf85237bf7de95b8401b9d88f72077d Mon Sep 17 00:00:00 2001 From: computezrmle <57127745+computezrmle@users.noreply.github.com> Date: Wed, 19 Jan 2022 20:34:47 +0100 Subject: [PATCH 07/11] Update dhrystone.h --- client/dhrystone.h | 1 - 1 file changed, 1 deletion(-) diff --git a/client/dhrystone.h b/client/dhrystone.h index 6200c988045..3cc3a8aadfe 100644 --- a/client/dhrystone.h +++ b/client/dhrystone.h @@ -1,6 +1,5 @@ #if defined __APPLE__ || __cplusplus >= 201703L -//#if defined __APPLE__ || __cplusplus >= 202002L #define REG #else #define REG register From dccbd33b4a4b2874e2a9554bdf9af5bd566cc528 Mon Sep 17 00:00:00 2001 From: computezrmle <57127745+computezrmle@users.noreply.github.com> Date: Wed, 19 Jan 2022 20:40:47 +0100 Subject: [PATCH 08/11] Update whetstone.cpp --- client/whetstone.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/whetstone.cpp b/client/whetstone.cpp index f001b782306..230efb1210b 100644 --- a/client/whetstone.cpp +++ b/client/whetstone.cpp @@ -98,7 +98,7 @@ int whetstone(double& flops, double& cpu_time, double min_cpu_time) { SPDP x,y,z; long j,k,l, jjj; SPDP e1[4]; - double startsec, finisec; + double startsec = 0.0, finisec = 0.0; double KIPS; int xtra, ii; int x100 = 1000; // chosen to make each pass take about 0.1 sec From 8892171ff6cfa2ee6812d22a5f0b9a98d49163c7 Mon Sep 17 00:00:00 2001 From: computezrmle <57127745+computezrmle@users.noreply.github.com> Date: Thu, 20 Jan 2022 11:05:20 +0100 Subject: [PATCH 09/11] revoke changes from wrong branch --- client/whetstone.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/whetstone.cpp b/client/whetstone.cpp index 230efb1210b..f001b782306 100644 --- a/client/whetstone.cpp +++ b/client/whetstone.cpp @@ -98,7 +98,7 @@ int whetstone(double& flops, double& cpu_time, double min_cpu_time) { SPDP x,y,z; long j,k,l, jjj; SPDP e1[4]; - double startsec = 0.0, finisec = 0.0; + double startsec, finisec; double KIPS; int xtra, ii; int x100 = 1000; // chosen to make each pass take about 0.1 sec From 89c2ceb9cee48a2dcc1055d7238d7e92f93944cb Mon Sep 17 00:00:00 2001 From: computezrmle <57127745+computezrmle@users.noreply.github.com> Date: Thu, 20 Jan 2022 11:05:24 +0100 Subject: [PATCH 10/11] revoke changes from wrong branch --- client/dhrystone.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/dhrystone.h b/client/dhrystone.h index 3cc3a8aadfe..60a298994d9 100644 --- a/client/dhrystone.h +++ b/client/dhrystone.h @@ -1,5 +1,5 @@ -#if defined __APPLE__ || __cplusplus >= 201703L +#ifdef __APPLE__ #define REG #else #define REG register From 155a20924853588b37fd62b5d7addff6d9738d16 Mon Sep 17 00:00:00 2001 From: computezrmle <57127745+computezrmle@users.noreply.github.com> Date: Thu, 20 Jan 2022 11:05:27 +0100 Subject: [PATCH 11/11] revoke changes from wrong branch --- client/dhrystone.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/dhrystone.cpp b/client/dhrystone.cpp index 1370f960106..3346ae6191a 100644 --- a/client/dhrystone.cpp +++ b/client/dhrystone.cpp @@ -90,7 +90,7 @@ int dhrystone( unsigned long Loops; DS_DATA dd; - double startclock = 0.0, endclock = 0.0; + double startclock, endclock; double benchtime; double Dhrystones_Per_Second;