From fa44b3c169cbe70a5feedd8e7a00bca6ba112551 Mon Sep 17 00:00:00 2001
From: Rom Walton <rwalton@ssl.berkeley.edu>
Date: Sun, 28 Jun 2015 15:18:17 -0400
Subject: [PATCH] VBOX: Create a new job file flag for dealing with the scratch
 directory feature.

---
 samples/vboxwrapper/vbox_mscom_impl.cpp | 5 +++++
 samples/vboxwrapper/vbox_vboxmanage.cpp | 6 +++++-
 samples/vboxwrapper/vboxjob.cpp         | 2 ++
 samples/vboxwrapper/vboxjob.h           | 3 +++
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/samples/vboxwrapper/vbox_mscom_impl.cpp b/samples/vboxwrapper/vbox_mscom_impl.cpp
index 74ba4ef545..a00161cc13 100644
--- a/samples/vboxwrapper/vbox_mscom_impl.cpp
+++ b/samples/vboxwrapper/vbox_mscom_impl.cpp
@@ -833,7 +833,11 @@ int VBOX_VM::create_vm() {
             TRUE
         );
         if (CHECK_ERROR(rc)) goto CLEANUP;
+    }
 
+    // Enable the scratch folder if a scratch folder is specified.
+    //
+    if (enable_scratch_directory) {
         vboxlog_msg("Enabling scratch shared directory for VM.");
         rc = pMachine->CreateSharedFolder(
             CComBSTR("scratch"),
@@ -844,6 +848,7 @@ int VBOX_VM::create_vm() {
         if (CHECK_ERROR(rc)) goto CLEANUP;
     }
 
+
 CLEANUP:
     if (pMachine) {
         pMachine->SaveSettings();
diff --git a/samples/vboxwrapper/vbox_vboxmanage.cpp b/samples/vboxwrapper/vbox_vboxmanage.cpp
index 2d2849c8f5..c6906a8316 100644
--- a/samples/vboxwrapper/vbox_vboxmanage.cpp
+++ b/samples/vboxwrapper/vbox_vboxmanage.cpp
@@ -611,7 +611,7 @@ int VBOX_VM::create_vm() {
         }
     }
 
-    // Enable the shared folders if a shared folder is specified.
+    // Enable the shared folder if a shared folder is specified.
     //
     if (enable_shared_directory) {
         vboxlog_msg("Enabling shared directory for VM.");
@@ -621,7 +621,11 @@ int VBOX_VM::create_vm() {
 
         retval = vbm_popen(command, output, "enable shared dir");
         if (retval) return retval;
+    }
 
+    // Enable the scratch folder if a scratch folder is specified.
+    //
+    if (enable_scratch_directory) {
         vboxlog_msg("Enabling scratch shared directory for VM.");
         command  = "sharedfolder add \"" + vm_name + "\" ";
         command += "--name \"scratch\" ";
diff --git a/samples/vboxwrapper/vboxjob.cpp b/samples/vboxwrapper/vboxjob.cpp
index 156d5a716c..0c0c441209 100644
--- a/samples/vboxwrapper/vboxjob.cpp
+++ b/samples/vboxwrapper/vboxjob.cpp
@@ -109,6 +109,7 @@ void VBOX_JOB::clear() {
     temporary_exit_trigger_file.clear();
     enable_cern_dataformat = false;
     enable_shared_directory = false;
+    enable_scratch_directory = false;
     enable_floppyio = false;
     enable_cache_disk = false;
     enable_isocontextualization = false;
@@ -164,6 +165,7 @@ int VBOX_JOB::parse() {
         else if (xp.parse_bool("enable_network", enable_network)) continue;
         else if (xp.parse_bool("network_bridged_mode", network_bridged_mode)) continue;
         else if (xp.parse_bool("enable_shared_directory", enable_shared_directory)) continue;
+        else if (xp.parse_bool("enable_scratch_directory", enable_scratch_directory)) continue;
         else if (xp.parse_bool("enable_floppyio", enable_floppyio)) continue;
         else if (xp.parse_bool("enable_cache_disk", enable_cache_disk)) continue;
         else if (xp.parse_bool("enable_isocontextualization", enable_isocontextualization)) continue;
diff --git a/samples/vboxwrapper/vboxjob.h b/samples/vboxwrapper/vboxjob.h
index ff9d690d1b..5dd7bf5d95 100644
--- a/samples/vboxwrapper/vboxjob.h
+++ b/samples/vboxwrapper/vboxjob.h
@@ -89,6 +89,9 @@ public:
     // whether to use shared directory infrastructure
     bool enable_shared_directory;
 
+    // whether to use scratch directory infrastructure
+    bool enable_scratch_directory;
+
     // whether to use floppy io infrastructure
     bool enable_floppyio;
 
-- 
GitLab