Skip to main content

Crate msb_krun

Crate msb_krun 

Source
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::ConsolePortOptions;
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::VmExecutionState;
pub use api::vm::VmGenerationId;
pub use api::vm::VmGenerationRequest;
pub use api::vm::VmGenerationState;
pub use api::vm::VmGenerationWaitOutcome;
pub use api::vm::VmMemoryRestoreSource;
pub use api::vm::VmMemoryRestoreTarget;
pub use api::vm::VmMemoryState;
pub use api::vm::VmPauseGeneration;

Modules§

api
Native Rust API for libkrun.
backends
Custom backend support for libkrun.

Structs§

BlockDeviceMetrics
Per-device block metrics.
BlockMetrics
Aggregate block metrics.
CpuMetrics
CPU metrics.
ExecutionState
Complete hypervisor-owned execution state at one VM-wide pause generation.
FilesystemMetrics
Filesystem metrics.
GuestMemoryRange
One non-empty guest-physical byte range.
HostCpuId
Identifies one logical processor in the host’s processor topology.
MemoryBaselineToken
Runtime-local capability naming the latest successfully published memory baseline.
MemoryCaptureOptions
Bounded streaming configuration for memory generation production.
MemoryCapturePlan
Candidate memory generation that has not yet become the retained baseline.
MemoryCaptureStats
Measurements from producing one full or incremental memory generation.
MemoryGeneration
Identifies one candidate or published memory-content generation.
MemoryMetrics
Memory metrics.
MemoryTopologyGeneration
Identifies one immutable guest-memory topology within a running VMM.
MetricsHandle
Cloneable handle for point-in-time VM metrics.
NumaDistance
One entry in the dense guest NUMA distance matrix.
NumaNodeConfig
One dense guest proximity domain and the host policy for its backing memory.
NumaTopology
A fully resolved guest NUMA description supplied by the embedding runtime.
PlacementReport
The host placement that was actually established before guest execution begins.
PrivateMemoryBacking
Immutable, read-only file ownership retained by every resulting mapping.
PrivateMemoryRegion
One complete guest RAM region in an immutable flat memory image.
VcpuExecutionState
Opaque state for one vCPU, interpreted only by its matching backend codec.
VmMetrics
Point-in-time VM metrics.
VsockConnectRequest
Metadata for a guest-initiated connection to a registered host port.
VsockNotifier
Cloneable wake handle for a custom vsock stream.

Enums§

ExecutionArchitecture
Guest instruction-set architecture represented by an execution-state artifact.
ExecutionBackend
Hypervisor backend that produced an execution-state artifact.
FullCaptureReason
Reason an incremental request must safely use complete capture instead.
HostMemoryPolicy
Host backing policy for guest RAM belonging to a resolved node.
IncrementalCaptureDecision
Result of requesting capture relative to a retained baseline.
MemoryCaptureKind
Describes whether a candidate capture is complete or relative to a retained baseline.
MemoryPlacementResult
The effective host-memory placement of ordinary guest RAM and hotplug capacity.
VcpuPlacementResult
The effective host placement of one guest vCPU.
VsockShutdown
Direction requested by a guest shutdown packet.

Traits§

ConsolePortBackend
Trait for custom virtio-console port backends.
DynFileSystem
Object-safe filesystem trait for dynamic dispatch.
MemoryCaptureSink
Receives one bounded, ordered memory-generation stream.
VsockPortBackend
Factory for custom, in-process services exposed on one host vsock port.
VsockStreamBackend
One nonblocking byte stream served by a custom vsock backend.