Repository navigation
feat(host): save and resume the state of jailed Firecracker VMs - #439
Merged
kalaspuff merged 4 commits intoNov 7, 2026
Merged
Conversation
A jailed Firecracker writes its state at the root of its chroot, as the jail's user: the host takes both files out to the sandbox's saved/, each opened without following a link and checked to be a regular file of that user's with no other name, and gives them to root. A resume makes the jail as a start does, but without a configuration, with the disks the VM booted with and the saved state lent to the jail's user, loads it, and only then links the vsock's socket out. The host keeps a jailed VM's configuration with its own paths in the VM's directory, for its size and the disks a resume needs, and records whether a state was saved in a jail, which it then resumes only in one. Refs #437
A root-only unit test runs a jailed VM's save and resume against a jailer and Firecracker's API standing in, in a real jail; another checks that the host takes out of a jail only what Firecracker saved there. CI's root step runs it, and stopped_sandboxes_resume_where_they_were, which no longer turns the jailer off. Refs #437
A jailed VM's state goes through its chroot: the host takes it out as the files Firecracker made there, and lends it to a new jail to load. A state resumes only as jailed as it was saved, and a VM that an earlier fctl started in a jail stops without saving its state, since the host has no record of its configuration. Refs #437
…ume-state-of-jailed-firecrac
kalaspuff
approved these changes
Nov 7, 2026
kalaspuff
deleted the
fctl/859-save-and-resume-state-of-jailed-firecrac
branch
November 7, 2026 10:26
This was referenced Nov 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On a host that runs as root, Firecracker VMs run through the jailer (#434), and until now they stopped without saving their state (#431), so a message booted the sandbox again from its disk and Claude started over. Now a jailed VM saves and resumes as an unjailed one does:
vmstateandmemoryat the root of its chroot, as the jail's user. The host takes each out to the sandbox'ssaved/by the file it opened without following a link, after checking that it is a regular file of the jail's user's with no other name, so that the jail can't hand it a link to a host file or the disk it was lent. It then gives each to root, mode 0600.jail.json, so that it is given back. It starts the jailer, loads the state (PUT /snapshot/load), and only then links the vsock's socket out, since Firecracker makes it as the state loads. The state's links in the chroot go once it has loaded.CI's Firecracker job verifies it with KVM on x86_64. Its root step now also runs
stopped_sandboxes_resume_where_they_werewith the jailer, which it used to turn off. There a jailed VM saved its state in 3.3 s (60 MiB of memory on disk) and resumed in 78 ms with its programs running, as fast as an unjailed one, and Firecracker ran as a jail's user again after the resume. As root,boots_a_sandboxand the package-caches test now save and resume their jailed VMs too. A new root-only unit test, which CI's root step runs and I ran here as root, makes real jails for a start, a save and a resume against a stand-in jailer and Firecracker API. Other unit tests cover the checks on what the host takes out of a jail, and a state saved in or out of a jail being refused on the other side.Worth confirming
jaileron or off, or moving a host to root, lets the states kept before go: those sandboxes boot from their disks, with a line in the session's log saying why.Fixes #437
Refs #345
fctl session
Note
Medium risk. It changes how root-run hosts stop and resume Firecracker VMs, moving files between a jail the VM controls and the host's own directories as root, so a flaw in those checks could let a jailed VM reach host files.
What it does. Jailed Firecracker VMs (hosts running as root) now save their state when they stop and resume from it, as unjailed VMs already did. The host takes the
vmstateandmemoryfiles out of the jail's chroot with checks that they are plain files of the jail's user, and on resume it builds a new jail with hard links of the disks and saved state, loads the snapshot and links the vsock socket out. States record whether they were saved in a jail and resume only in the same mode, and the host now keeps a jailed VM's configuration in the sandbox directory.Saved states and jailer mode. Turning
jaileron or off, or moving a host to root, discards states saved before, and VMs a v0.30.2 host started in a jail stop without saving once, then boot from disk.fctl review's first look at
8a005a1· 6 files, +886 −213 · Review agent settings