2011-08-03 22:36:29 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2010 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
|
|
|
|
|
|
|
|
#ifndef _VBOX_H_
|
|
|
|
#define _VBOX_H_
|
|
|
|
|
2011-12-20 22:12:07 +00:00
|
|
|
// raw floppy drive device
|
|
|
|
class FloppyIO;
|
|
|
|
|
|
|
|
// represents a VirtualBox VM
|
2011-08-04 00:24:42 +00:00
|
|
|
struct VBOX_VM {
|
2011-08-03 22:36:29 +00:00
|
|
|
VBOX_VM();
|
2011-12-20 22:12:07 +00:00
|
|
|
~VBOX_VM();
|
|
|
|
|
|
|
|
// Floppy IO abstraction
|
|
|
|
FloppyIO* pFloppy;
|
2011-08-03 22:36:29 +00:00
|
|
|
|
2011-09-14 04:16:00 +00:00
|
|
|
// name of the OS the VM runs
|
2011-08-03 22:36:29 +00:00
|
|
|
std::string os_name;
|
2011-09-14 04:16:00 +00:00
|
|
|
// size of the memory allocation for the VM, in megabytes
|
2011-08-03 22:36:29 +00:00
|
|
|
std::string memory_size_mb;
|
2011-09-14 04:16:00 +00:00
|
|
|
// name of the virtual machine disk image file
|
2011-08-03 22:36:29 +00:00
|
|
|
std::string image_filename;
|
2011-12-20 22:12:07 +00:00
|
|
|
// name of the virtual machine floppy disk image file
|
|
|
|
std::string floppy_image_filename;
|
2011-09-14 04:16:00 +00:00
|
|
|
// unique name for the VM
|
2011-08-04 00:24:42 +00:00
|
|
|
std::string vm_name;
|
2011-12-20 22:12:07 +00:00
|
|
|
// required CPU core count
|
2011-12-19 19:10:24 +00:00
|
|
|
std::string vm_cpu_count;
|
2011-12-20 22:59:06 +00:00
|
|
|
// maximum amount of wall-clock time this VM is allowed to run before
|
|
|
|
// considering itself done.
|
2011-12-25 20:17:53 +00:00
|
|
|
double job_duration;
|
2011-12-20 22:12:07 +00:00
|
|
|
// is the VM suspended?
|
2011-08-03 22:36:29 +00:00
|
|
|
bool suspended;
|
2011-12-23 18:21:48 +00:00
|
|
|
// is network access temporarily suspended?
|
2011-08-27 04:13:50 +00:00
|
|
|
bool network_suspended;
|
2011-12-23 18:21:48 +00:00
|
|
|
// is VM even online?
|
|
|
|
bool online;
|
2011-12-25 03:57:56 +00:00
|
|
|
// Has the VM crashed?
|
|
|
|
bool crashed;
|
2011-12-20 22:12:07 +00:00
|
|
|
// whether to use CERN specific data structures
|
|
|
|
bool enable_cern_dataformat;
|
2011-12-19 19:10:24 +00:00
|
|
|
// whether to use shared directory infrastructure at all
|
2011-08-03 22:36:29 +00:00
|
|
|
bool enable_shared_directory;
|
2011-12-23 20:14:42 +00:00
|
|
|
// whether to use floppy io infrastructure at all
|
|
|
|
bool enable_floppyio;
|
2011-09-14 04:16:00 +00:00
|
|
|
// whether we were instructed to only register the VM.
|
|
|
|
// useful for debugging VMs.
|
|
|
|
bool register_only;
|
2011-12-20 22:12:07 +00:00
|
|
|
// whether to allow network access at all
|
|
|
|
bool enable_network;
|
2011-12-25 13:18:51 +00:00
|
|
|
// the following for optional port forwarding
|
|
|
|
int pf_host_port;
|
|
|
|
// dynamically assigned
|
|
|
|
int pf_guest_port;
|
|
|
|
// specified in config file
|
2011-09-14 04:16:00 +00:00
|
|
|
|
2011-08-03 22:36:29 +00:00
|
|
|
int run();
|
|
|
|
int stop();
|
|
|
|
int pause();
|
|
|
|
int resume();
|
|
|
|
void cleanup();
|
2012-01-02 04:30:42 +00:00
|
|
|
void poll(bool log_state = true);
|
2011-08-03 22:36:29 +00:00
|
|
|
bool is_running();
|
2011-12-23 18:21:48 +00:00
|
|
|
bool is_paused();
|
2011-08-03 22:36:29 +00:00
|
|
|
|
|
|
|
int register_vm();
|
2011-12-21 05:55:08 +00:00
|
|
|
int register_vm_firewall_rules();
|
2011-08-03 22:36:29 +00:00
|
|
|
bool is_hdd_registered();
|
2011-08-04 00:24:42 +00:00
|
|
|
bool is_registered();
|
2011-08-03 22:36:29 +00:00
|
|
|
int deregister_stale_vm();
|
|
|
|
int deregister_vm();
|
2011-09-16 19:16:12 +00:00
|
|
|
int start();
|
2011-08-26 19:19:28 +00:00
|
|
|
int set_network_access(bool enabled);
|
2011-08-27 04:13:50 +00:00
|
|
|
int set_cpu_usage_fraction(double);
|
|
|
|
int set_network_max_bytes_sec(double);
|
2011-09-16 19:16:12 +00:00
|
|
|
int get_process_id(int& process_id);
|
|
|
|
int get_network_bytes_sent(double& sent);
|
|
|
|
int get_network_bytes_received(double& received);
|
2012-01-02 04:30:42 +00:00
|
|
|
int get_system_log(std::string& log);
|
2011-12-25 03:57:56 +00:00
|
|
|
int get_vm_log(std::string& log);
|
2011-12-20 22:12:07 +00:00
|
|
|
int read_floppy(std::string& data);
|
|
|
|
int write_floppy(std::string& data);
|
2011-12-25 13:18:51 +00:00
|
|
|
int get_port_forwarding_port();
|
2011-08-03 22:36:29 +00:00
|
|
|
|
2012-01-02 17:07:39 +00:00
|
|
|
int initialize();
|
|
|
|
int get_install_directory(std::string& dir);
|
|
|
|
int get_slot_directory(std::string& dir);
|
|
|
|
int vbm_popen(
|
2012-01-02 04:30:42 +00:00
|
|
|
std::string& command, std::string& output, const char* item, bool log_error = true, bool retry_failures = true
|
2011-09-16 17:25:36 +00:00
|
|
|
);
|
2012-01-02 17:07:39 +00:00
|
|
|
int vbm_popen_raw(
|
2012-01-02 04:30:42 +00:00
|
|
|
std::string& command, std::string& output
|
2011-12-25 03:57:56 +00:00
|
|
|
);
|
2011-08-03 22:36:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|