Crate virtualbox_rs

Source
Expand description

virtualbox_rs is a Rust library for interacting with VirtualBox through its SDK.

This library provides a comprehensive set of bindings to manage VirtualBox VMs, including creating, deleting, and modifying virtual machines, handling snapshots, and configuring various VM settings such as network adapters, audio settings, and encryption.

§Features

  • Create and manage VirtualBox VMs
  • Handle VM snapshots
  • Configure VM settings (network, audio, encryption, etc.)
  • Support for different VirtualBox API versions (6.1 and 7.0)

§Example

use virtualbox_rs::{Session, VirtualBox, VirtualBoxClient};
use virtualbox_rs::enums::SessionType;

VirtualBoxClient::check_version().unwrap();
let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();

let machine_mut = session.get_machine().unwrap();
let progress = machine_mut.delete_snapshot_and_all_children("278ef54a-2e75-4aba-b212-551af4c69725").unwrap();
progress.wait_for_completion(-1).unwrap();

§Supported Platforms

This library has been tested on:

  • FreeBSD 14.1
  • Ubuntu 24.04

§Supported VirtualBox Versions

This library supports VirtualBox versions 6.1, 7.0, and 7.1. By default, the library is built for version 7.1. To change the target version, enable the corresponding feature flag: v7_1, v7_0, or v6_1. If multiple versions are specified, the library will be built for the highest version available.

Important: Running the library with an incompatible VirtualBox version is likely to result in a Segmentation fault. Before using the library, ensure compatibility by invoking VirtualBoxClient::check_version().unwrap();. If the versions do not match, the program should terminate immediately.

§Note

Not everything has been implemented yet. The library emphasizes providing examples for each method, which should simplify its usage.

Modules§

enums
event_detail

Structs§

Appliance
Represents a platform-independent appliance in OVF format.
AudioAdapter
Interface for controlling the virtual machine AudioAdapter.
AudioSettings
The AudioSettings interface represents the audio settings for a virtual machine. More…
BIOSSettings
Placeholder Struct
BandwidthControl
Controls the bandwidth groups of one machine used to cap I/O done by a VM.
BandwidthGroup
Represents one bandwidth group.
CPUProfile
CPU profile
Certificate
X.509 certificate details.
CloudNetwork
Reference to the official documentation:
Console
Interface for controlling the virtual machine console.
DHCPServer
The DHCPServer interface represents the VirtualBox DHCP server configuration.
DataStream
The IDataStream interface is used to retrieve a data stream.
Display
The Display interface represents the virtual machine’s display
Event
Abstract parent interface for VirtualBox events
EventListener
Event listener.
EventSource
Event source.
ExtPackManager
Interface for managing VirtualBox Extension Packs. Reference to the official documentation:
FirmwareSettings
Interface for managing VirtualBox Extension Packs. Reference to the official documentation:
Framebuffer
IFramebuffer Interface Reference
GraphicsAdapter
The GraphicsAdapter interface represents the graphics adapter of the virtual machine.
Guest
The IGuest interface represents information about the operating system running inside the virtual machine.
GuestDebugControl
Controls the guest debug settings of one virtual machine.
GuestFile
Implementation of the IFile object for files in the guest.
GuestInternalGetStatistics
GuestOSType
Reference to the official documentation:
GuestProcess
Implementation of the IProcess object for processes the host has started in the guest.
GuestSession
A guest session represents one impersonated user account in the guest, so every operation will use the same credentials specified when creating the session object via Guest::create_session
Host
The IHost interface represents the physical machine that this VirtualBox installation runs on. More…
HostAudioDevice
Represents an audio device provided by the host OS.
HostNetworkInterface
Represents one of host’s network interfaces
HostOnlyNetwork
Reference to the official documentation:
Keyboard
The Keyboard interface represents the virtual machine’s keyboard.
Machine
The Machine interface represents a virtual machine, or guest, created in VirtualBox.
Medium
The IMedium interface represents virtual storage for a machine’s hard disks, CD/DVD or floppy drives.
MediumAttachment
The IMediumAttachment interface links storage media to virtual machines. More…
MediumFormat
The IMediumFormat interface represents a medium format.
MediumIO
The MediumIO interface is used to access and modify the content of a medium.
Mouse
The IMouse interface represents the virtual machine’s mouse.
NATNetwork
Reference to the official documentation:
NetworkAdapter
The NetworkAdapter interface represents the audio settings for a virtual machine. More…
NvramStore
Provides access to the NVRAM store collecting all permanent states from different sources (UEFI, TPM, etc.).
PCIDeviceAttachment
Information about PCI attachments.
ParallelPort
The IParallelPort interface represents the virtual parallel port device.
PerformanceCollector
The IPerformanceCollector interface represents a service that collects and stores performance metrics data.
Platform
Properties of a specific virtualization platform.
PlatformARM
The ARM-specific platform properties for a virtual machine.
PlatformProperties
Properties of a specific virtualization platform.
PlatformX86
The x86 specific platform properties for a virtual machine.
Progress
The Progress interface is used to track and control asynchronous tasks within VirtualBox.
RecordingSettings
The RecordingSettings interface represents recording settings of the virtual machine. More…
Resolution
SerialPort
Virtual serial port device
Session
The Session interface represents a client process and allows for locking virtual machines (represented by Machine objects) to prevent conflicting changes to the machine.
SharedFolder
The SharedFolder interface represents a folder in the host computer’s file system accessible from the guest OS running inside a virtual machine using an associated logical name. More…
Snapshot
The Snapshot interface represents a snapshot of the virtual machine.
StorageController
Represents a storage controller that is attached to a virtual machine (Machine)
SystemProperties
The SystemProperties interface represents global properties of the given VirtualBox installation.
Token
The Token interface represents a token passed to an API client, which triggers cleanup actions when it is explicitly released by calling the abandon method (preferred, as it is accurately defined when the release happens), or when the object reference count drops to 0.
TrustedPlatformModule
The TrustedPlatformModule interface represents the settings of the virtual machine’s trusted platform module.
USBController
Reference to the official documentation:
USBDevice
Virtual USB device attached to the virtual machine
USBDeviceFilters
Reference to the official documentation:
Unattended
Represents a platform-independent Unattended in OVF format.
UpdateAgent
Abstract parent interface for handling updateable software components.
VFSExplorer
The VFSExplorer interface unifies access to different file system types.
VRDEServer
Reference to the official documentation:
VboxError
VideoModeHint
VirtualBox
The VirtualBox interface represents the main interface exposed by the product that provides virtual machine management.
VirtualBoxClient
Convenience interface for client applications.
VirtualBoxErrorInfo
The IVirtualBoxErrorInfo interface represents extended error information.
VirtualSystemDescription
Represents one virtual system (machine) in an appliance.

Enums§

VboxErrorType