msb_krun 0.1.9

Native Rust API for libkrun microVMs
Documentation

msb_krun - Native Rust API for libkrun microVMs.

This crate provides a builder-pattern API for creating and entering microVMs using libkrun's VMM infrastructure.

Lifecycle

[Vm::enter()] never returns on success. When the guest shuts down, the VMM calls _exit(), killing the entire process. enter() only returns Err if something fails before the VMM takes over.

Example

use msb_krun::{VmBuilder, Result};

fn main() -> Result<()> {
    VmBuilder::new()
        .machine(|m| m.vcpus(4).memory_mib(2048))
        .fs(|fs| fs.root("/path/to/rootfs"))
        .exec(|e| e.path("/bin/myapp").args(["--flag"]).env("HOME", "/root"))
        .build()?
        .enter()?;

    unreachable!()
}