Commit Graph
9 Commits
Author SHA1 Message Date
marvin f2b68004ae Support host:guest mount syntax with WORKINGDIR resolution
CI / build (pull_request) Successful in 12s
--mount now accepts <host-path>:<guest-path> (Docker-style). When the
guest path is omitted, the host path is used. Non-absolute guest paths
are resolved against the image WORKINGDIR, which is written to
/slim/workdir at build time and read by slim-init.sh at boot.

Changes:
- qemu.rs: Parse host:guest spec, pass guest path (not host path) on
  the kernel cmdline as slim.mount=<tag>:<base64(guest_path)>
- inject.rs: Accept working_dir param, write /slim/workdir into rootfs
- build.rs: Pass config.working_dir to inject()
- slim-init.sh: Read /slim/workdir, resolve relative guest paths
  against it before mounting
- test.sh: Test host:guest absolute paths (multi-mount) and relative
  guest path resolved against WORKINGDIR

Addresses PR #9 review comment from @hulthe.
2026-09-10 12:12:07 +02:00
marvin 8454c8e407 Fix U3: escape commas in --mount path for QEMU -virtfs
CI / build (pull_request) Successful in 13s
QEMU QemuOpts splits on commas; escape literal commas in the host
path as ,, per QEMU convention to prevent option injection and
boot failures on paths containing commas.

Fix U5: extract b64dec() helper in slim-init.sh

Deduplicate the 3-line base64 fallback decode block used by both
the slim.mount and slim.cmd handlers into a single b64dec() function.

Fix U6: add multi-mount test case

test_mount now passes two --mount flags and asserts both slim0
and slim1 9p tags appear, covering the multi-mount tag-generation
path.
2026-09-10 11:08:41 +02:00
marvin f931705971 Add --mount flag for 9p host directory sharing
CI / build (pull_request) Successful in 13s
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 00:18:38 +02:00
hulthe c2a9f00fc0 Inject universal /slim/init instead of requiring container-specific setup
CI / build (pull_request) Successful in 36s
CI / build (push) Successful in 13s
slim now works with any Containerfile by injecting distro-agnostic scripts
at build time:

- /slim/init: mounts special filesystems, configures networking (static
  QEMU slirp), sets up cgroup2, timezone, and rootless container prereqs.
  Parses slim.cmd=<base64> from the kernel cmdline for runtime overrides,
  otherwise execs /slim/exec.

- /slim/exec: generated from the image's CMD/ENTRYPOINT (via podman image
  inspect), overridable via --cmd at build and run time.

Changes:
- New src/inject.rs: inspect image config, infer command, generate
  /slim/exec script, inject /slim/ into mounted rootfs
- New src/scripts/slim-init.sh: the universal init script (include_str!)
- build.rs: rename --init to --cmd, inject scripts before packing,
  drop Meta::save, restructure to ensure unmount always runs
- qemu.rs: hardcode init=/slim/init, add --cmd (base64 on cmdline),
  drop Meta::load, add -no-reboot
- Remove src/meta.rs and meta.toml (no longer needed)
- Cargo.toml: add serde_json + base64, remove unused walkdir + cpio + toml
- Example Containerfiles simplified to plain FROM + CMD
- New example/test.sh for manual verification
- README updated for new workflow
2026-09-08 21:58:01 +02:00
hulthe 506213ed9a Fixes
CI / build (push) Successful in 14s
2026-09-06 16:09:20 +02:00
hulthe 7dd818db68 Progress
CI / build (push) Successful in 14s
2026-09-04 17:01:46 +02:00
hulthe ec05936d2f Add Arch Linux example
CI / build (push) Successful in 10s
2026-08-29 21:04:35 +02:00
hulthe 41bc570bfb Print qemu command 2026-08-29 21:04:27 +02:00
hulthe 56a76ce934 Add basic README.md with an example
CI / build (push) Successful in 11s
2026-08-26 23:46:57 +02:00