#virtualbox #helper #vbox

vboxhelper

API wrapper around VirtualBox's command line tools

8 releases

Uses new Rust 2021

0.3.3 Feb 4, 2022
0.3.2 Aug 10, 2021
0.2.0 Apr 19, 2021
0.1.8 Apr 19, 2021
0.1.0 Mar 31, 2021

#13 in #helper

0BSD license

43KB
1.5K SLoC

vboxhelper

vboxhelper provides a strongly typed API on top of the VirtualBox command line tools.


lib.rs:

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.

Dependencies

~2MB
~46K SLoC