marvin 90de50dfed Add --mount flag for 9p host directory sharing
Add support for sharing host directories into the VM via QEMU 9p
(virtio-9p).  The --mount flag can be repeated; each host directory
appears at the same absolute path inside the VM.

Design:
- QEMU: each --mount gets a short 9p tag (slim0, slim1, …) via
  -virtfs local,path=…,mount_tag=slimN,security_model=mapped-xattr.
  Tags are kept short because 9p mount_tag has a ~31-byte limit.
- Kernel cmdline: the full destination path is passed as
  slim.mount=<tag>:<base64(path)> so the init script knows where to
  mount each tag.  Base64 avoids issues with spaces/special chars.
- slim-init.sh: after networking, parse slim.mount= entries, mkdir -p
  the destination, and mount -t 9p <tag> <dest> -o trans=virtio,version=9p2000.L

Tests verify: 9p share detection via sysfs mount_tag, 9p entry in
mount output, file content accessible at the expected path, and clean
VM exit.
2026-09-10 12:19:59 +02:00
2026-08-26 19:25:20 +02:00

slim

Turning containers into bootable VMs

Example

# Build the container
podman build ./example/alpine -t slim-alpine

# Make the container bootable. slim injects /slim/init and /slim/exec,
# then packs the rootfs as a qcow2 disk.
slim build qcow2 slim-alpine

# Boot the image using QEMU. The container's CMD runs automatically.
slim run slim-alpine

# Override the command at runtime (base64-encoded on the kernel cmdline):
slim run slim-alpine --cmd '/bin/sh'

# Override the command at build time (baked into /slim/exec):
slim build qcow2 slim-alpine --cmd '/bin/sh'

# Cleanup
slim image rm slim-alpine
podman image rm slim-alpine

Kernel

slim boots VMs using a shared kernel at $XDG_DATA_HOME/slim-rs/registry/vmlinuz. Place a suitable x86 bzImage there before running slim run.

S
Description
Turn container images into bootable VMs
Readme
251 KiB
Languages
Rust 75.1%
Shell 24.7%
Dockerfile 0.2%