2012-12-12 01:33:26 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2010-2012 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
// Provide cross-platform interfaces for making changes to VirtualBox
|
|
|
|
|
2014-11-18 21:12:56 +00:00
|
|
|
#ifndef _VBOX_COMMON_H_
|
|
|
|
#define _VBOX_COMMON_H_
|
2012-12-12 01:33:26 +00:00
|
|
|
|
2014-01-16 16:54:06 +00:00
|
|
|
// Vboxwrapper errors
|
|
|
|
//
|
|
|
|
#define VBOXWRAPPER_ERR_RECOVERABLE -1000
|
|
|
|
|
2014-01-22 19:34:20 +00:00
|
|
|
// Vboxwrapper diagnostics
|
|
|
|
//
|
|
|
|
#define REPLAYLOG_FILENAME "vbox_replay.txt"
|
|
|
|
#define TRACELOG_FILENAME "vbox_trace.txt"
|
|
|
|
|
2014-05-29 05:12:24 +00:00
|
|
|
// represents a VirtualBox Guest Log Timestamp
|
2014-08-03 06:07:22 +00:00
|
|
|
struct VBOX_TIMESTAMP {
|
2014-05-29 05:12:24 +00:00
|
|
|
int hours;
|
|
|
|
int minutes;
|
|
|
|
int seconds;
|
|
|
|
int milliseconds;
|
|
|
|
};
|
|
|
|
|
2014-10-03 08:03:11 +00:00
|
|
|
// represents the state of a intermediate upload
|
|
|
|
struct INTERMEDIATE_UPLOAD {
|
|
|
|
std::string file;
|
|
|
|
bool reported;
|
|
|
|
bool ignore;
|
|
|
|
|
|
|
|
INTERMEDIATE_UPLOAD() {
|
|
|
|
clear();
|
|
|
|
}
|
|
|
|
void clear() {
|
|
|
|
file = "";
|
|
|
|
reported = false;
|
|
|
|
ignore = false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-08-03 06:07:22 +00:00
|
|
|
struct PORT_FORWARD {
|
|
|
|
int host_port; // 0 means assign dynamically
|
|
|
|
int guest_port;
|
|
|
|
bool is_remote;
|
|
|
|
|
|
|
|
PORT_FORWARD() {
|
|
|
|
host_port = 0;
|
|
|
|
guest_port = 0;
|
|
|
|
is_remote = false;
|
|
|
|
}
|
2014-11-23 17:46:28 +00:00
|
|
|
int get_host_port(); // assign host port
|
2014-08-03 06:07:22 +00:00
|
|
|
};
|
|
|
|
|
2014-11-23 17:46:28 +00:00
|
|
|
class VBOX_BASE {
|
2014-05-29 05:12:24 +00:00
|
|
|
public:
|
2014-11-23 17:46:28 +00:00
|
|
|
VBOX_BASE();
|
|
|
|
~VBOX_BASE();
|
2012-12-12 01:33:26 +00:00
|
|
|
|
2013-11-08 23:02:12 +00:00
|
|
|
std::string virtualbox_home_directory;
|
|
|
|
std::string virtualbox_install_directory;
|
2014-08-13 17:46:38 +00:00
|
|
|
std::string virtualbox_guest_additions;
|
2012-12-28 18:40:09 +00:00
|
|
|
std::string virtualbox_version;
|
|
|
|
|
2014-11-18 21:12:56 +00:00
|
|
|
FloppyIONS::FloppyIO* pFloppy;
|
2012-12-12 01:33:26 +00:00
|
|
|
|
2013-11-20 13:42:54 +00:00
|
|
|
std::string vm_log;
|
2014-08-14 04:27:30 +00:00
|
|
|
// last polled copy of the log file
|
2014-05-29 05:12:24 +00:00
|
|
|
VBOX_TIMESTAMP vm_log_timestamp;
|
2014-08-14 04:27:30 +00:00
|
|
|
// last VM guest log entry detected
|
2012-12-12 01:33:26 +00:00
|
|
|
std::string vm_master_name;
|
2014-08-14 04:27:30 +00:00
|
|
|
// unique name for the VM
|
2013-09-18 18:45:52 +00:00
|
|
|
std::string vm_master_description;
|
2014-08-14 04:27:30 +00:00
|
|
|
// unique description for the VM
|
2012-12-12 01:33:26 +00:00
|
|
|
std::string vm_name;
|
2014-08-14 04:27:30 +00:00
|
|
|
// unique name for the VM or UUID of a stale VM if deregistering it
|
2012-12-12 01:33:26 +00:00
|
|
|
std::string vm_cpu_count;
|
2014-08-14 04:27:30 +00:00
|
|
|
// required CPU core count
|
2012-12-12 01:33:26 +00:00
|
|
|
std::string image_filename;
|
2014-08-14 04:27:30 +00:00
|
|
|
// name of the virtual machine disk image file
|
2014-07-07 19:46:59 +00:00
|
|
|
std::string iso_image_filename;
|
2014-08-14 04:27:30 +00:00
|
|
|
// name of the virtual machine iso9660 disk image file
|
2014-07-07 20:03:46 +00:00
|
|
|
std::string cache_disk_filename;
|
2014-08-14 04:27:30 +00:00
|
|
|
// name of the virtual machine cache disk image file
|
2014-07-07 20:03:46 +00:00
|
|
|
std::string floppy_image_filename;
|
2014-08-14 04:27:30 +00:00
|
|
|
// name of the virtual machine floppy disk image file
|
2014-05-29 13:46:10 +00:00
|
|
|
double current_cpu_time;
|
2014-08-14 04:27:30 +00:00
|
|
|
// amount of CPU time consumed by the VM (note: use get_vm_cpu_time())
|
2012-12-12 01:33:26 +00:00
|
|
|
bool suspended;
|
2014-08-14 04:27:30 +00:00
|
|
|
// is the VM suspended?
|
2012-12-12 01:33:26 +00:00
|
|
|
bool network_suspended;
|
2014-08-14 04:27:30 +00:00
|
|
|
// is network access temporarily suspended?
|
2012-12-12 01:33:26 +00:00
|
|
|
bool online;
|
2014-08-14 04:27:30 +00:00
|
|
|
// is VM even online?
|
2013-12-12 15:34:49 +00:00
|
|
|
bool saving;
|
2014-08-14 04:27:30 +00:00
|
|
|
// Is VM saving from checkpoint?
|
2013-12-12 15:34:49 +00:00
|
|
|
bool restoring;
|
2014-08-14 04:27:30 +00:00
|
|
|
// Is VM restoring from checkpoint?
|
2012-12-12 01:33:26 +00:00
|
|
|
bool crashed;
|
2014-08-14 04:27:30 +00:00
|
|
|
// Has the VM crashed?
|
2012-12-12 01:33:26 +00:00
|
|
|
bool register_only;
|
2014-08-14 04:27:30 +00:00
|
|
|
// whether we were instructed to only register the VM.
|
|
|
|
// useful for debugging VMs.
|
2012-12-12 01:33:26 +00:00
|
|
|
int rd_host_port;
|
2014-08-14 04:27:30 +00:00
|
|
|
// for optional remote desktop; dynamically assigned
|
2012-12-12 01:33:26 +00:00
|
|
|
bool headless;
|
2013-12-04 17:40:14 +00:00
|
|
|
|
2014-06-21 02:33:10 +00:00
|
|
|
/////////// THE FOLLOWING SPECIFIED IN VBOX_JOB.XML //////////////
|
|
|
|
// some of these don't really belong in this class
|
|
|
|
|
|
|
|
std::string os_name;
|
|
|
|
// name of the OS the VM runs
|
|
|
|
std::string vm_disk_controller_type;
|
|
|
|
// the type of disk controller to emulate
|
|
|
|
std::string vm_disk_controller_model;
|
|
|
|
// the disk controller model to emulate
|
2014-09-24 17:06:05 +00:00
|
|
|
double memory_size_mb;
|
|
|
|
// size of the memory allocation for the VM, in megabytes
|
2014-08-19 18:48:10 +00:00
|
|
|
bool enable_cern_dataformat;
|
|
|
|
// whether to use CERN specific data structures
|
2014-07-07 19:46:59 +00:00
|
|
|
bool enable_isocontextualization;
|
|
|
|
// whether to use an iso9660 image to implement VM contextualization (e.g. uCernVM)
|
2014-07-07 20:03:46 +00:00
|
|
|
bool enable_cache_disk;
|
|
|
|
// whether to add an extra cache disk for systems like uCernVM
|
2014-06-21 02:33:10 +00:00
|
|
|
bool enable_network;
|
|
|
|
// whether to allow network access
|
2014-08-20 02:28:38 +00:00
|
|
|
bool network_bridged_mode;
|
2014-08-19 03:33:51 +00:00
|
|
|
// use bridged mode for network
|
2014-06-21 02:33:10 +00:00
|
|
|
bool enable_shared_directory;
|
|
|
|
// whether to use shared directory infrastructure
|
|
|
|
bool enable_floppyio;
|
|
|
|
// whether to use floppy io infrastructure
|
|
|
|
bool enable_remotedesktop;
|
|
|
|
// whether to enable remote desktop functionality
|
2014-10-29 22:20:50 +00:00
|
|
|
bool enable_gbac;
|
|
|
|
// whether to enable GBAC functionality
|
2014-06-21 02:33:10 +00:00
|
|
|
double job_duration;
|
|
|
|
// maximum amount of wall-clock time this VM is allowed to run before
|
|
|
|
// considering itself done.
|
|
|
|
std::string fraction_done_filename;
|
|
|
|
// name of file where app will write its fraction done
|
2014-08-03 06:07:22 +00:00
|
|
|
int pf_guest_port; // if nonzero, do port forwarding for Web GUI
|
|
|
|
int pf_host_port; // AFAIK this isn't needed
|
|
|
|
std::vector<PORT_FORWARD> port_forwards;
|
2014-06-21 02:33:10 +00:00
|
|
|
double minimum_checkpoint_interval;
|
|
|
|
// minimum time between checkpoints
|
|
|
|
std::vector<std::string> copy_to_shared;
|
2014-07-01 20:31:25 +00:00
|
|
|
// list of files to copy from slot dir to shared/
|
2014-06-21 02:33:10 +00:00
|
|
|
std::vector<std::string> trickle_trigger_files;
|
2014-07-01 20:31:25 +00:00
|
|
|
// if find file of this name in shared/, send trickle-up message
|
|
|
|
// with variety = filename, contents = file contents
|
2014-10-03 08:03:11 +00:00
|
|
|
std::vector<INTERMEDIATE_UPLOAD> intermediate_upload_files;
|
|
|
|
// if find file of this name in shared/, send specified file
|
2014-07-01 20:31:25 +00:00
|
|
|
std::string completion_trigger_file;
|
|
|
|
// if find this file in shared/, task is over.
|
|
|
|
// File can optionally contain exit code (first line)
|
2014-10-24 16:53:38 +00:00
|
|
|
// 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)
|
2014-07-01 20:31:25 +00:00
|
|
|
// and stderr text (subsequent lines).
|
|
|
|
// Addresses a problem where VM doesn't shut down properly
|
2014-06-21 02:33:10 +00:00
|
|
|
|
|
|
|
/////////// END VBOX_JOB.XML ITEMS //////////////
|
|
|
|
|
2014-11-18 21:12:56 +00:00
|
|
|
int vm_pid;
|
|
|
|
int vboxsvc_pid;
|
|
|
|
#ifdef _WIN32
|
|
|
|
// the handle to the process for the VM
|
|
|
|
// NOTE: we get a handle to the pid right after we parse it from the
|
|
|
|
// log files so we can adjust the process priority and retrieve the process
|
|
|
|
// exit code in case it crashed or was terminated. Without an outstanding
|
|
|
|
// handle to the process, the OS is free to reuse the pid for some other
|
|
|
|
// executable.
|
|
|
|
HANDLE vm_pid_handle;
|
|
|
|
|
|
|
|
// the handle to the vboxsvc process created by us in the sandbox'ed environment
|
|
|
|
HANDLE vboxsvc_pid_handle;
|
|
|
|
#endif
|
2012-12-12 01:33:26 +00:00
|
|
|
|
2014-11-23 17:46:28 +00:00
|
|
|
virtual int initialize();
|
|
|
|
virtual int create_vm();
|
|
|
|
virtual int register_vm();
|
|
|
|
virtual int deregister_vm(bool delete_media);
|
|
|
|
virtual int deregister_stale_vm();
|
|
|
|
virtual void poll(bool log_state = true);
|
|
|
|
virtual int start();
|
|
|
|
virtual int stop();
|
|
|
|
virtual int poweroff();
|
|
|
|
virtual int pause();
|
|
|
|
virtual int resume();
|
|
|
|
virtual int create_snapshot(double elapsed_time);
|
|
|
|
virtual int cleanup_snapshots(bool delete_active);
|
|
|
|
virtual int restore_snapshot();
|
2013-12-04 17:40:14 +00:00
|
|
|
|
2014-11-16 04:14:11 +00:00
|
|
|
virtual int run(bool do_restore_snapshot);
|
|
|
|
virtual void cleanup();
|
|
|
|
|
|
|
|
virtual void dump_hypervisor_logs(bool include_error_logs);
|
|
|
|
virtual void dump_hypervisor_status_reports();
|
|
|
|
virtual void dump_vmguestlog_entries();
|
|
|
|
|
|
|
|
virtual int is_registered();
|
|
|
|
virtual bool is_system_ready(std::string& message);
|
|
|
|
virtual bool is_vm_machine_configuration_available();
|
|
|
|
virtual bool is_hdd_registered();
|
|
|
|
virtual bool is_extpack_installed();
|
|
|
|
virtual bool is_logged_failure_vm_extensions_disabled();
|
|
|
|
virtual bool is_logged_failure_vm_extensions_in_use();
|
|
|
|
virtual bool is_logged_failure_vm_extensions_not_supported();
|
|
|
|
virtual bool is_logged_failure_host_out_of_memory();
|
|
|
|
virtual bool is_logged_failure_guest_job_out_of_memory();
|
|
|
|
virtual bool is_virtualbox_version_newer(int maj, int min, int rel);
|
|
|
|
|
|
|
|
virtual int get_install_directory(std::string& dir);
|
|
|
|
virtual int get_version_information(std::string& version);
|
|
|
|
virtual int get_guest_additions(std::string& dir);
|
|
|
|
virtual int get_slot_directory(std::string& dir);
|
|
|
|
virtual int get_default_network_interface(std::string& iface);
|
|
|
|
virtual int get_vm_network_bytes_sent(double& sent);
|
|
|
|
virtual int get_vm_network_bytes_received(double& received);
|
|
|
|
virtual int get_vm_process_id();
|
|
|
|
virtual int get_vm_exit_code(unsigned long& exit_code);
|
|
|
|
virtual double get_vm_cpu_time();
|
|
|
|
|
|
|
|
virtual int get_system_log(std::string& log, bool tail_only = true, unsigned int buffer_size = 8192);
|
|
|
|
virtual int get_vm_log(std::string& log, bool tail_only = true, unsigned int buffer_size = 8192);
|
|
|
|
virtual int get_trace_log(std::string& log, bool tail_only = true, unsigned int buffer_size = 8192);
|
|
|
|
|
|
|
|
virtual int set_network_access(bool enabled);
|
|
|
|
virtual int set_cpu_usage(int percentage);
|
|
|
|
virtual int set_network_usage(int kilobytes);
|
|
|
|
|
|
|
|
virtual int read_floppy(std::string& data);
|
|
|
|
virtual int write_floppy(std::string& data);
|
|
|
|
|
|
|
|
virtual void lower_vm_process_priority();
|
|
|
|
virtual void reset_vm_process_priority();
|
|
|
|
|
|
|
|
virtual void sanitize_output(std::string& output);
|
2012-12-12 01:33:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|