|
| 1 | +# microvm-runtime |
| 2 | + |
| 3 | +[](https://crates.io/crates/microvm-runtime) |
| 4 | +[](https://docs.rs/microvm-runtime) |
| 5 | + |
| 6 | +Firecracker microVM driver for decentralized Tangle operators. |
| 7 | + |
| 8 | +A pure-Rust primitive. No HTTP server, no auth layer, no sessions, no business |
| 9 | +logic — just the driver that speaks the Firecracker API over its unix socket |
| 10 | +and exposes a small lifecycle trait. Tangle blueprints (the operator binaries) |
| 11 | +consume it directly as a Cargo dependency — operators **are** the hosts, so |
| 12 | +there is no second process to deploy. |
| 13 | + |
| 14 | +## Why this exists |
| 15 | + |
| 16 | +Every Tangle blueprint that wants microVM isolation (sandbox blueprint, |
| 17 | +microvm blueprint, future cloud-style blueprints) needs the same driver. This |
| 18 | +crate is that driver, extracted into a single primitive with a narrow surface |
| 19 | +so it can be hardened in one place. |
| 20 | + |
| 21 | +## Status |
| 22 | + |
| 23 | +`0.1.0-alpha.1` — extracted from `microvm-blueprint`. Lifecycle works |
| 24 | +(create / start / stop / snapshot / destroy). Production hardening is the |
| 25 | +next several releases: |
| 26 | + |
| 27 | +- [ ] Network configuration (TAP / bridge / iptables NAT) |
| 28 | +- [ ] Vsock device for guest↔host RPC |
| 29 | +- [ ] Snapshot restore (`PUT /snapshot/load`) |
| 30 | +- [ ] Console log ring buffer for post-mortem |
| 31 | +- [ ] Graceful shutdown (SIGTERM → wait → SIGKILL) |
| 32 | +- [ ] Jailer wrapper (chroot / cgroup v2 / seccomp / UID-GID mapping) |
| 33 | +- [ ] Rate limiters on drives and NICs |
| 34 | +- [ ] Egress firewall per session |
| 35 | +- [ ] Metrics polling (`GET /vm` for CPU / memory / network) |
| 36 | +- [ ] VM rename for warm-pool handoff |
| 37 | + |
| 38 | +See [`docs/ROADMAP.md`](docs/ROADMAP.md) for the per-phase plan. |
| 39 | + |
| 40 | +## Usage |
| 41 | + |
| 42 | +```rust |
| 43 | +use microvm_runtime::{adapters::firecracker::{FirecrackerConfig, FirecrackerVmProvider}, VmProvider, VmQuery}; |
| 44 | + |
| 45 | +let provider = FirecrackerVmProvider::from_env(); |
| 46 | +provider.create_vm("vm-1")?; |
| 47 | +provider.start_vm("vm-1")?; |
| 48 | +provider.snapshot_vm("vm-1", "snap-a")?; |
| 49 | +provider.stop_vm("vm-1")?; |
| 50 | +provider.destroy_vm("vm-1")?; |
| 51 | +``` |
| 52 | + |
| 53 | +## Environment variables |
| 54 | + |
| 55 | +| Variable | Default | Purpose | |
| 56 | +| --- | --- | --- | |
| 57 | +| `MICROVM_FIRECRACKER_BIN` | `/usr/local/bin/firecracker` | Firecracker binary path | |
| 58 | +| `MICROVM_FIRECRACKER_KERNEL` | `/var/lib/firecracker/vmlinux` | Linux kernel image | |
| 59 | +| `MICROVM_FIRECRACKER_ROOTFS` | `/var/lib/firecracker/rootfs/default.ext4` | Rootfs image | |
| 60 | +| `MICROVM_FIRECRACKER_SOCKET_DIR` | `/var/run/microvm/sockets` | Per-VM API socket parent dir | |
| 61 | +| `MICROVM_FIRECRACKER_STATE_DIR` | `/var/lib/microvm/state` | Per-VM state dir | |
| 62 | +| `MICROVM_FIRECRACKER_VCPU` | `1` | Default vCPU count | |
| 63 | +| `MICROVM_FIRECRACKER_MEM_MIB` | `256` | Default memory size | |
| 64 | + |
| 65 | +## License |
| 66 | + |
| 67 | +[Unlicense](LICENSE) — public domain. |
0 commit comments