Cross-Platform
Unified API across Linux (KVM) and macOS (Virtualization.framework). Write once, run on both platforms.
A batteries-included Rust library for running lightweight VMs with a focus on security, simplicity, and embeddability.
use capsa::{Capsa, LinuxDirectBootConfig};
use std::time::Duration;
#[tokio::main]
async fn main() -> capsa::Result<()> {
// Create and start a VM
let vm = Capsa::vm(LinuxDirectBootConfig::new("kernel", "initrd"))
.cpus(2)
.memory_mb(512)
.console_enabled()
.build()
.await?;
// Interact via console
let console = vm.console().await?;
console.wait_for_timeout("# ", Duration::from_secs(30)).await?;
let output = console.exec("uname -a", Duration::from_secs(5)).await?;
println!("Kernel: {}", output);
// Clean shutdown
vm.stop().await?;
Ok(())
}Run untrusted code in isolated VMs with fine-grained network policies. Allow only specific API endpoints while blocking everything else.
let policy = NetworkPolicy::deny_all()
.allow_domain("api.anthropic.com")
.allow_domain("*.github.com");
let vm = Capsa::sandbox()
.network(NetworkMode::user_nat().policy(policy).build())
.run("/bin/agent", &[])
.build().await?;Pre-warm VM pools for fast test execution. Each test gets a fresh VM without boot overhead.
let pool = Capsa::pool(config)
.console_enabled()
.build(4) // 4 pre-warmed VMs
.await?;
// In tests
let vm = pool.reserve().await?;
// Run test...
drop(vm); // VM automatically replacedShare specific directories with guests while maintaining isolation. Perfect for build environments and code execution.
// Linux only - shared directories require virtio-fs
let vm = Capsa::sandbox()
.share("./workspace", "/mnt/code", MountMode::ReadWrite)
.run("/bin/sh", &["-c", "make -C /mnt/code"])
.build().await?;| Feature | Linux (KVM) | macOS |
|---|---|---|
| Linux Direct Boot | Supported | Supported |
| UEFI Boot | - | Supported |
| virtio-fs Shares | Supported | Coming Soon |
| Networking | Supported | Supported |
| VM Sockets (vsock) | Supported | Supported |
| VM Pools | Supported | Supported |
| Sandbox Mode | Supported | Supported |