Expand description
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!()
}Re-exports§
pub use api::builder::VmBuilder;pub use api::builders::FsBuilder;pub use api::builders::VsockBuilder;pub use api::builders::ConsoleBuilder;pub use api::builders::ExecBuilder;pub use api::builders::KernelBuilder;pub use api::builders::MachineBuilder;pub use api::builders::NumaBuilder;pub use api::builders::NumaNodeBuilder;pub use api::error::BuildError;pub use api::error::ConfigError;pub use api::error::Error;pub use api::error::Result;pub use api::error::RuntimeError;pub use api::exit_handle::ExitHandle;pub use api::vm::Vm;pub use api::vm::VmControl;pub use api::vm::VmCpuState;pub use api::vm::VmMemoryState;
Modules§
Structs§
- Block
Device Metrics - Per-device block metrics.
- Block
Metrics - Aggregate block metrics.
- CpuMetrics
- CPU metrics.
- Filesystem
Metrics - Filesystem metrics.
- Host
CpuId - Identifies one logical processor in the host’s processor topology.
- Memory
Metrics - Memory metrics.
- Metrics
Handle - Cloneable handle for point-in-time VM metrics.
- Numa
Distance - One entry in the dense guest NUMA distance matrix.
- Numa
Node Config - One dense guest proximity domain and the host policy for its backing memory.
- Numa
Topology - A fully resolved guest NUMA description supplied by the embedding runtime.
- Placement
Report - The host placement that was actually established before guest execution begins.
- VmMetrics
- Point-in-time VM metrics.
- Vsock
Connect Request - Metadata for a guest-initiated connection to a registered host port.
- Vsock
Notifier - Cloneable wake handle for a custom vsock stream.
Enums§
- Host
Memory Policy - Host backing policy for guest RAM belonging to a resolved node.
- Memory
Placement Result - The effective host-memory placement of ordinary guest RAM and hotplug capacity.
- Vcpu
Placement Result - The effective host placement of one guest vCPU.
- Vsock
Shutdown - Direction requested by a guest shutdown packet.
Traits§
- Console
Port Backend - Trait for custom virtio-console port backends.
- DynFile
System - Object-safe filesystem trait for dynamic dispatch.
- Vsock
Port Backend - Factory for custom, in-process services exposed on one host vsock port.
- Vsock
Stream Backend - One nonblocking byte stream served by a custom vsock backend.