Back to Microsandbox

Rust Examples

examples/rust/README.md

0.4.41.8 KB
Original Source

Rust Examples

Prerequisites

  • Rust (2024 edition)
  • msb + libkrunfw installed (via cargo build with the prebuilt feature, or manually)
  • For root-bind and root-block: git submodule update --init --recursive

Running

Each example is a standalone binary crate in the workspace:

sh
cargo run -p <example-name>

For example:

sh
cargo run -p oci-root
cargo run -p net-basic
cargo run -p fs-read-stream

Examples

ExampleCommandDescription
root-ocicargo run -p root-ociOCI image rootfs
root-bindcargo run -p root-bindBind-mounted local directory
root-blockcargo run -p root-blockqcow2 disk image
rootfs-patchcargo run -p rootfs-patchPre-boot filesystem patches
init-handoffcargo run -p init-handoffHand PID 1 off to systemd
volume-namedcargo run -p volume-namedNamed volumes shared across sandboxes
volume-diskcargo run -p volume-diskDisk image volumes (raw / qcow2) at guest paths
snapshot-forkcargo run -p snapshot-forkSnapshot a stopped sandbox and boot a fresh one from it
fs-read-streamcargo run -p fs-read-streamStreaming file read
metrics-streamcargo run -p metrics-streamStreaming resource metrics
shell-attachcargo run -p shell-attachInteractive shell attach
net-basiccargo run -p net-basicBasic networking
net-dnscargo run -p net-dnsDNS filtering
net-policycargo run -p net-policyNetwork policies
net-portscargo run -p net-portsPort publishing
net-secretscargo run -p net-secretsSecret injection
net-tlscargo run -p net-tlsTLS interception