js: describe host file systems in worker-mode snapshots where the docs still said inline only: VsockSnapshot.mounts, createKernel's restore, MountTable.snapshotBlocker() and the WASI binfmt test's unmount; rewrap the docs

This commit is contained in:
Pooya Parsa
2026-11-28 20:16:24 +00:00
parent 74e1486df7
commit 516bace61a
6 changed files with 17 additions and 13 deletions

View File

@@ -276,8 +276,9 @@ parts that are easy to get wrong.
- Host file systems in snapshots (mounts.ts, 9p.ts; in worker mode with
`commit`, below): inline the 9p server runs on the kernel's thread, so
`VsockDevice.saveState()` saves the mounts at the snapshot point
(`VsockSnapshot.mounts`: `MountTable.save()`). Every guest task is parked and a 9p request holds
its task (killable wait) until answered, so the sessions are quiet
(`VsockSnapshot.mounts`: `MountTable.save()`). Every guest task is
parked and a 9p request holds its task (killable wait) until answered,
so the sessions are quiet
there; one that is not (`MountTable.snapshotBusy()`, through
`VsockDevice.hostBusy`) makes the snapshot point busy. Per mount: its
path, read-only flag, export name, the vsock connection's ports and
@@ -417,8 +418,8 @@ parts that are easy to get wrong.
delivered, `snapshot-held`'s `vsockIn`, against the owner's count);
either fails the commit, and the kernel goes on (a SnapshotCommitError,
as a busy snapshot point inline). `test/api.test.ts` saves a held open
file and resumes it in a worker. The worker
runs `KernelInstance.snapshot()` and answers `snapshot-result` with the
file and resumes it in a worker. The worker runs
`KernelInstance.snapshot()` and answers `snapshot-result` with the
memory transferred (no second copy; shared from 2 GiB). Every `snapshot` is answered before
`exit`: the exit waits for the snapshots in progress (at most 60 s of
awake time, `awakeTimeout()`), answers any still open as failed, then

View File

@@ -326,7 +326,8 @@ Open:
while its disks are unchanged; vsock sessions and guest TCP
connections do not survive a restore (the guest's ends are reset), but
host file systems do, with their open files (in worker mode only with
`commit`: other worker-mode snapshots refuse while anything is mounted). Next, roughly in order:
`commit`: other worker-mode snapshots refuse while anything is
mounted). Next, roughly in order:
- **Rewind and fork**: restore one snapshot again after the disk moved
on, or several times. Needs the disk state frozen at the seal, e.g.
the CowDisk overlay frozen as a read-only layer under a new one.

View File

@@ -66,7 +66,8 @@ export interface CreateKernelOptions {
* TCP connections do not survive: the guest's ends are reset, except
* detachable terminal sessions (spawn() with `detachable`), which the
* guest keeps detached for attach() (the snapshot's `ttys`). Host file
* systems do (in worker mode from a snapshot({ commit })): `mounts` must give one for each mount path
* systems do, inline and in worker mode (a worker's own snapshot keeps
* them only with commit): `mounts` must give one for each mount path
* in the snapshot, read-only as it was, and the guest's open files on
* it are opened again by path (a file gone meanwhile answers ESTALE);
* nothing of their files is in the snapshot. Other `mounts` are

View File

@@ -250,9 +250,9 @@ export class MountTable {
/**
* Why a snapshot cannot be started now, or undefined. `keep`: the
* snapshot can keep mounts (inline: the 9p server runs on the kernel's
* thread, so it is saved at the snapshot point); without it (worker
* mode) any mount refuses, since a restored machine would not get its
* 9p session back.
* thread, so it is saved at the snapshot point; in worker mode only with
* commit, saved while the worker holds the kernel); without it any mount
* refuses, since a restored machine would not get its 9p session back.
*/
snapshotBlocker(keep = false): string | undefined {
if (this.#boot) return "createKernel's mounts are still being mounted";

View File

@@ -143,9 +143,10 @@ export interface VsockSnapshot {
guestCid: number;
rxMax: number;
/**
* Host file systems (inline mode): each mount's 9p session and the
* vsock connection it runs on, which a restore takes over; the kernel
* keeps exactly these connections and resets every other.
* Host file systems (inline, or in worker mode with commit): each
* mount's 9p session and the vsock connection it runs on, which a
* restore takes over; the kernel keeps exactly these connections and
* resets every other.
*/
mounts?: MountsSnapshot;
}

View File

@@ -415,7 +415,7 @@ async function snapshotCheck() {
(/root/work/calls.wasm copy 4096 </dev/zero 2>/tmp/w/p.err; echo $? > /tmp/w/p.rc) | sleep 100000 >/dev/null 2>&1 &`);
await until(() => wasi.stats.running === 3, 5000, "three programs running");
await sleep(300);
// In a worker a snapshot may not have host file systems (they resume inline only).
// In a worker only a snapshot with commit may have host file systems, and these have none.
if (worker) await vm.mounts.get("/mnt/kw")!.unmount();
const old = wasi;
// One without stop: the guest and the programs go on.