diff --git a/.agents/js.md b/.agents/js.md index c21a720..1a89b63 100644 --- a/.agents/js.md +++ b/.agents/js.md @@ -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 diff --git a/.agents/status.md b/.agents/status.md index 97a24b5..1d85166 100644 --- a/.agents/status.md +++ b/.agents/status.md @@ -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. diff --git a/js/core/instance.ts b/js/core/instance.ts index fcc8fd6..659d7e4 100644 --- a/js/core/instance.ts +++ b/js/core/instance.ts @@ -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 diff --git a/js/core/mounts.ts b/js/core/mounts.ts index 2251f2b..c675108 100644 --- a/js/core/mounts.ts +++ b/js/core/mounts.ts @@ -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"; diff --git a/js/core/vsock.ts b/js/core/vsock.ts index 6ae95be..2b22261 100644 --- a/js/core/vsock.ts +++ b/js/core/vsock.ts @@ -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; } diff --git a/test/wasi-binfmt.ts b/test/wasi-binfmt.ts index 39c278d..039c72a 100644 --- a/test/wasi-binfmt.ts +++ b/test/wasi-binfmt.ts @@ -415,7 +415,7 @@ async function snapshotCheck() { (/root/work/calls.wasm copy 4096 /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.