Expand description
This crate is probably not what you hoped it was – in fact, it’s probably exactly what you feared. Rather than integrate against VirtualBox’s COM interfaces it will call the command line tools and parse their outputs.
Perhaps not surprisingly, this crate originally began as a bash script and slowly morphed into what it is today.
§Examples
Terminate a virtual machine named myvm and revert it to a snapshot named mysnap.
use std::time::Duration;
use vboxhelper::*;
let vm = "myvm".parse::<VmId>().unwrap();
controlvm::kill(&vm).unwrap();
let ten_seconds = Duration::new(10, 0);
wait_for_croak(&vm, Some((ten_seconds, TimeoutAction::Error)));
// revert to a snapshot
let snap = "mysnap".parse::<snapshot::SnapshotId>().unwrap();
snapshot::restore(&vm, Some(snap)).unwrap();
§VirtualBox Versions
This crate will generally attempt to track the latest version of VirtualBox.
§Environment variables
In some cases vboxhelper will execute external commands with no intention
of parsing their output. In these situations vboxhelper will by default
consume the child processes’ output. This behavior can be changed by
setting the VBOXHELPER_VERBOSE
environment variable; setting its value to
"1"
will cause the library to output to be directed to stdout and stderr
respectively.
If the variable VBOXHELPER_LOGS
is set to a valid directory vboxhelper
may use it to store log files.
Re-exports§
Modules§
- controlvm
- Control the run state of a virtual machine.
- err
- guest
- nics
- snapshot
- Manage virtual machine snapshots.
- storage
- vmid
- Abstraction of a virtual machine identifier.
Structs§
- VmInfo
- A structured representation of a virtual machine’s state and configuration.
Enums§
- Headless
- Control whether running a VM headless should block until VM terminates or if it should return as soon as the VM has been started in the background.
- RunContext
- Control whether a virtual machine is run with a GUI or in Headless mode.
- Shutdown
- Timeout
Action - VmState
- VirtualBox virtual machine states.
Functions§
- get_pid
- Get the process id of the guest virtual machine.
- get_
running_ vms_ list - Get a list of all running virtual machines.
- get_
vm_ info - Get structured information about a virtual machine.
- get_
vm_ info_ map - Get information about a virtual machine as a map.
- get_
vm_ list - Get a list of virtual machines.
- have_vm
- is_
vm_ running - is_
vm_ state - Check whether a virtual machine is currently in a certain state.
- try_
get_ pid - Wrapper method around
get_pid()
to retry getting the guest’s PID. - wait_
for_ croak - Wait for a virtual machine to self-terminate.
- wait_
for_ state - Wait for a virtual machine to enter an expected state.