vboxwrapper: add <copy_cmdline_to_shared> option to job file

Tells vboxwrapper to copy its cmdline args to shared/cmdline.

This lets you use the cmdline mechanism as a way to pass
info to the VM that would otherwise have to go in a file.

Note: the cmdline can be fairly large.
It shares the wu.xml_doc field with file descriptions.
This field can be up to 64KB (MySQL blob size)
This commit is contained in:
David Anderson 2017-01-26 20:08:35 -08:00
parent ed2e3e472a
commit 4b9a55b438
3 changed files with 76 additions and 56 deletions

View File

@ -128,6 +128,7 @@ void VBOX_JOB::clear() {
pf_host_port = 0;
port_forwards.clear();
intermediate_upload_files.clear();
copy_cmdline_to_shared = false;
// Initialize default values
vm_disk_controller_type = "ide";
@ -190,6 +191,7 @@ int VBOX_JOB::parse() {
copy_to_shared.push_back(str);
continue;
}
else if (xp.parse_bool("copy_cmdline_to_shared", copy_cmdline_to_shared)) continue;
else if (xp.parse_string("trickle_trigger_file", str)) {
trickle_trigger_files.push_back(str);
continue;

View File

@ -59,109 +59,113 @@ public:
void clear();
int parse();
// name of the OS the VM runs
std::string os_name;
// name of the OS the VM runs
// the type of disk controller to emulate
std::string vm_disk_controller_type;
// the type of disk controller to emulate
// the disk controller model to emulate
std::string vm_disk_controller_model;
// the disk controller model to emulate
// size of the memory allocation for the VM, in megabytes
double memory_size_mb;
// size of the memory allocation for the VM, in megabytes
// whether to use CERN specific data structures
bool enable_cern_dataformat;
// whether to use CERN specific data structures
// whether to use an iso9660 image to implement VM contextualization (e.g. uCernVM)
bool enable_isocontextualization;
// whether to use an iso9660 image to implement VM contextualization (e.g. uCernVM)
// whether to add an extra cache disk for systems like uCernVM
bool enable_cache_disk;
// whether to add an extra cache disk for systems like uCernVM
// whether to put the iso as the first boot device
bool boot_iso;
// whether to put the iso as the first boot device
// whether to allow network access
bool enable_network;
// whether to allow network access
// use bridged mode for network
bool network_bridged_mode;
// use bridged mode for network
// whether to use shared directory infrastructure
bool enable_shared_directory;
// whether to use shared directory infrastructure
// whether to use scratch directory infrastructure
bool enable_scratch_directory;
// whether to use scratch directory infrastructure
// whether to use floppy io infrastructure
bool enable_floppyio;
// whether to use floppy io infrastructure
// whether to enable remote desktop functionality
bool enable_remotedesktop;
// whether to enable remote desktop functionality
// whether to enable GBAC functionality
bool enable_gbac;
// whether to enable GBAC functionality
// whether to enable graphics support by way of
// http://boinc.berkeley.edu/trac/wiki/GraphicsApi#File
bool enable_graphics_support;
// whether to enable graphics support by way of
// http://boinc.berkeley.edu/trac/wiki/GraphicsApi#File
// capture screen shots during catastrophic events
bool enable_screenshots_on_error;
// capture screen shots during catastrophic events
// whether to use savestate instead of poweroff on exit
bool enable_vm_savestate_usage;
// whether to use savestate instead of poweroff on exit
// whether to disable automatic checkpoint support
bool disable_automatic_checkpoints;
// whether to disable automatic checkpoint support
// maximum amount of wall-clock time this VM is allowed to run before
// considering itself done.
double job_duration;
// maximum amount of wall-clock time this VM is allowed to run before
// considering itself done.
// name of file where app will write its fraction done
std::string fraction_done_filename;
// name of file where app will write its fraction done
// name of the file to check for a heartbeat (i.e. check mod time with stat)
std::string heartbeat_filename;
// name of the file to check for a heartbeat
// (i.e. check mod time with stat)
// check heartbeat interval
double minimum_heartbeat_interval;
// check heartbeat interval
// if nonzero, do port forwarding for Web GUI
int pf_guest_port;
int pf_host_port;
// if nonzero, do port forwarding for Web GUI
std::vector<VBOX_PORT_FORWARD> port_forwards;
// minimum time between checkpoints
double minimum_checkpoint_interval;
// minimum time between checkpoints
// list of files to copy from slot dir to shared/
std::vector<std::string> copy_to_shared;
// list of files to copy from slot dir to shared/
bool copy_cmdline_to_shared;
// copy the cmdline to shared/cmdline
// if find file of this name in shared/, send trickle-up message
// with variety = filename, contents = file contents
std::vector<std::string> trickle_trigger_files;
// if find file of this name in shared/, send trickle-up message
// with variety = filename, contents = file contents
// if find file of this name in shared/, send specified file
std::vector<VBOX_INTERMEDIATE_UPLOAD> intermediate_upload_files;
// if find file of this name in shared/, send specified file
// if find this file in shared/, task is over.
// File can optionally contain exit code (first line)
// 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 completion_trigger_file;
// if find this file in shared/, task is over.
// File can optionally contain exit code (first line)
// File can optionally contain is_notice bool (second line)
// and stderr text (subsequent lines).
// Addresses a problem where VM doesn't shut down properly
// if find this file in shared/, task is restarted at a later date.
// File can optionally contain restart delay (first line)
// 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 temporary_exit_trigger_file;
// if find this file in shared/, task is restarted at a later date.
// File can optionally contain restart delay (first line)
// File can optionally contain is_notice bool (second line)
// and stderr text (subsequent lines).
// Addresses a problem where VM doesn't shut down properly
};
#endif

View File

@ -514,23 +514,23 @@ int main(int argc, char** argv) {
}
}
// Choose a random interleave value for checkpoint intervals to stagger disk I/O.
// Choose a random interleave value for checkpoint intervals
// to stagger disk I/O.
//
struct stat vm_image_stat;
if (stat(IMAGE_FILENAME_COMPLETE, &vm_image_stat)) {
// Error
srand((int)time(NULL));
} else {
srand((int)(vm_image_stat.st_mtime * time(NULL)));
}
random_checkpoint_factor = (double)(((int)(drand() * 100000.0)) % 600);
srand((int)getpid());
random_checkpoint_factor = drand() * 600;
vboxlog_msg("Feature: Checkpoint interval offset (%d seconds)", (int)random_checkpoint_factor);
vboxlog_msg(
"Feature: Checkpoint interval offset (%d seconds)",
(int)random_checkpoint_factor
);
// Display trickle value if specified
//
if (trickle_period > 0.0) {
vboxlog_msg("Feature: Enabling trickle-ups (Interval: %f)", trickle_period);
vboxlog_msg(
"Feature: Enabling trickle-ups (Interval: %f)", trickle_period
);
}
// Check for architecture incompatibilities
@ -567,11 +567,11 @@ int main(int argc, char** argv) {
pVM->headless = false;
}
// Check for invalid confgiurations.
// Check for invalid configurations.
//
if (aid.using_sandbox && aid.vbox_window) {
vboxlog_msg("Invalid configuration detected.");
vboxlog_msg("NOTE: BOINC cannot be installed as a service and run VirtualBox in headfull mode at the same time.");
vboxlog_msg("NOTE: BOINC cannot be installed as a service and run VirtualBox in headful mode at the same time.");
boinc_temporary_exit(86400, "Incompatible configuration detected.");
}
@ -589,8 +589,9 @@ int main(int argc, char** argv) {
);
}
// Check to see if the system is in a state in which we expect to be able to run
// VirtualBox successfully. Sometimes the system is in a wierd state after a
// Check to see if the system is in a state in which
// we expect to be able to run VirtualBox successfully.
// Sometimes the system is in a weird state after a
// reboot and the system needs a little bit of time.
//
if (!pVM->is_system_ready(message)) {
@ -658,6 +659,19 @@ int main(int argc, char** argv) {
}
}
if (pVM->copy_cmdline_to_shared) {
FILE* f = fopen("shared/cmdline", "w");
if (!f) {
vboxlog_msg("Couldn't create shared/cmdline");
} else {
for (int i=1; i<argc; i++) {
fprintf(f, "%s ", argv[i]);
}
fprintf(f, "\n");
fclose(f);
}
}
// Configure Instance specific VM Parameters
//
pVM->vm_master_name = "boinc_";