Skip to main content

Crate arcbox_vz

Crate arcbox_vz 

Source
Expand description

Safe Rust bindings for Apple’s Virtualization.framework.

This crate provides ergonomic, async-first bindings to Apple’s Virtualization.framework, allowing you to create and manage virtual machines on macOS. All framework interaction happens in the bundled ArcBoxVZShim Swift static library (shim/), reached through the hand-written C ABI in shim_ffi.rs — see that file’s header for the boundary conventions.

§Features

  • Safe API: Minimize unsafe code exposure with safe Rust abstractions
  • Async-first: Native async/await support for all asynchronous operations

§Example

use arcbox_vz::{
    VirtualMachineConfiguration, LinuxBootLoader, GenericPlatform,
    SocketDeviceConfiguration, VZError,
};

#[tokio::main]
async fn main() -> Result<(), VZError> {
    let mut config = VirtualMachineConfiguration::new()?;
    config
        .set_cpu_count(2)
        .set_memory_size(512 * 1024 * 1024);

    let boot_loader = LinuxBootLoader::new("/path/to/kernel")?;
    config.set_boot_loader(boot_loader);

    let vm = config.build()?;
    vm.start().await?;

    Ok(())
}

§Platform Support

This crate only supports macOS 11.0 (Big Sur) and later. Attempting to compile on other platforms will result in a compilation error.

§Entitlements

Your application must have the com.apple.security.virtualization entitlement to use this framework. See Apple’s documentation for details.