Skip to content

backend: auto picks the engine, once per sandbox (#29) - #51

Merged
chxmxii merged 1 commit into
mainfrom
backend-auto
Oct 12, 2026
Merged

chxmxii merged 1 commit into
mainfrom
backend-auto

Conversation

@chxmxii

@chxmxii chxmxii commented Oct 12, 2026

Copy link
Copy Markdown
Member

Closes #29. Part of the v0.5 milestone.

New Boxfiles say backend: auto: box picks the engine so users don't have to.

How it picks

  • firecracker when it fits: the Boxfile is offline (network: none), has no host mounts, no warm pool and no forks, and the host can run it (x86_64 Linux, KVM, vhost-vsock). Its VMM holds no capabilities at all.
  • podman otherwise, which supports everything.
  • The pick and its reason are recorded with the sandbox. box inspect shows backend chosen by backend: auto (…reason…); box doctor shows what auto picks on this host.

Why the pick sticks

firecracker keeps /data as a disk, podman as a directory. A sandbox that silently changed engine would lose sight of its data, so:

  • the recorded engine stays while it can still serve the Boxfile;
  • a change it cannot serve switches engines only while /data is empty; otherwise box stops and prints how to move the data (box data export, box reset, box build, box data import);
  • an explicit backend: always wins, and a Boxfile without the key keeps podman, so existing sandboxes never move.

Firecracker's limits now live in one function, boxfile.FirecrackerFits, used by validation and by auto, so the two cannot disagree.

Also

  • box fork on a firecracker sandbox refuses up front with the reason and the way out, instead of failing at the first run.
  • Fixed: box reset did not reset a firecracker sandbox. It emptied the /data directory, but firecracker's /data is a disk, which survived. It now deletes the disk; the next boot makes an empty one.
  • Fixed: box inspect created a missing firecracker disk while reporting on it (through fcDataDisk). It only reads now.

Tests

  • Unit: picks firecracker when it fits and the host can run it; podman for a networked Boxfile or a host without firecracker, with the reason; stays on podman once data lives there even if firecracker would now fit; switches an empty sandbox, refuses (with the move recipe) one with data; a Boxfile without the key stays podman and records nothing.
  • Real VMs: a new offline sandbox lands on firecracker (6.1 kernel) and runs; a networked one on podman; forking the firecracker one is refused with the reason; box reset on firecracker really empties /data; box doctor reports the auto choice.

New Boxfiles say backend: auto. box picks firecracker when it fits -- the
Boxfile is offline, has no host mounts, no warm pool and no forks, and the
host can run it -- because its VMM holds no capabilities; podman otherwise.
The pick and its reason are recorded with the sandbox and shown by box
inspect; box doctor says what auto picks on this host.

The pick sticks: firecracker keeps /data as a disk and podman as a
directory, so a sandbox that changed engine would lose sight of its data. A
Boxfile change the recorded engine cannot serve switches only while /data is
empty; otherwise box stops and says how to move the data. An explicit
backend always wins, and a Boxfile without the key keeps podman, so existing
sandboxes never move. Firecracker's limits live in one place,
boxfile.FirecrackerFits, used by both validation and auto.

box fork on a firecracker sandbox now refuses up front and says why, rather
than failing at the first run.

Fixed on the way: box reset did not reset a firecracker sandbox -- it emptied
the /data directory, but firecracker's /data is a disk, which survived. It
now deletes the disk; the next boot makes an empty one. And box inspect
created a missing firecracker disk while reporting on it; it only reads now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chxmxii
chxmxii merged commit ff0e26a into main Oct 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

backend: auto, the default

1 participant