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§
Structs§
- Appliance
- Represents a platform-independent appliance in OVF format.
- Audio
Adapter - Interface for controlling the virtual machine AudioAdapter.
- Audio
Settings - The AudioSettings interface represents the audio settings for a virtual machine. More…
- BIOS
Settings - Placeholder Struct
- Bandwidth
Control - Controls the bandwidth groups of one machine used to cap I/O done by a VM.
- Bandwidth
Group - Represents one bandwidth group.
- CPUProfile
- CPU profile
- Certificate
- X.509 certificate details.
- Cloud
Network - Reference to the official documentation:
- Console
- Interface for controlling the virtual machine console.
- DHCP
Server - The DHCPServer interface represents the VirtualBox DHCP server configuration.
- Data
Stream - 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
- Event
Listener - Event listener.
- Event
Source - Event source.
- ExtPack
Manager - Interface for managing VirtualBox Extension Packs. Reference to the official documentation:
- Firmware
Settings - Interface for managing VirtualBox Extension Packs. Reference to the official documentation:
- Framebuffer
- IFramebuffer Interface Reference
- Graphics
Adapter - 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.
- Guest
Debug Control - Controls the guest debug settings of one virtual machine.
- Guest
File - Implementation of the IFile object for files in the guest.
- Guest
Internal GetStatistics - GuestOS
Type - Reference to the official documentation:
- Guest
Process - Implementation of the IProcess object for processes the host has started in the guest.
- Guest
Session - 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…
- Host
Audio Device - Represents an audio device provided by the host OS.
- Host
Network Interface - Represents one of host’s network interfaces
- Host
Only Network - 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.
- Medium
Attachment - The IMediumAttachment interface links storage media to virtual machines. More…
- Medium
Format - 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:
- Network
Adapter - The NetworkAdapter interface represents the audio settings for a virtual machine. More…
- Nvram
Store - Provides access to the NVRAM store collecting all permanent states from different sources (UEFI, TPM, etc.).
- PCIDevice
Attachment - Information about PCI attachments.
- Parallel
Port - The IParallelPort interface represents the virtual parallel port device.
- Performance
Collector - 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.
- Platform
Properties - Properties of a specific virtualization platform.
- Platform
X86 - The x86 specific platform properties for a virtual machine.
- Progress
- The Progress interface is used to track and control asynchronous tasks within VirtualBox.
- Recording
Settings - The
RecordingSettings
interface represents recording settings of the virtual machine. More… - Resolution
- Serial
Port - 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.
- Shared
Folder - 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.
- Storage
Controller - Represents a storage controller that is attached to a virtual machine (
Machine
) - System
Properties - 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.
- Trusted
Platform Module - 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
- USBDevice
Filters - Reference to the official documentation:
- Unattended
- Represents a platform-independent Unattended in OVF format.
- Update
Agent - Abstract parent interface for handling updateable software components.
- VFSExplorer
- The VFSExplorer interface unifies access to different file system types.
- VRDE
Server - Reference to the official documentation:
- Vbox
Error - Video
Mode Hint - Virtual
Box - The VirtualBox interface represents the main interface exposed by the product that provides virtual machine management.
- Virtual
BoxClient - Convenience interface for client applications.
- Virtual
BoxError Info - The IVirtualBoxErrorInfo interface represents extended error information.
- Virtual
System Description - Represents one virtual system (machine) in an appliance.