Snapshots
Save a running machine, GPU memory included, and pick up exactly where it left off, with savevm or migration to a file.
A snapshot is the whole running machine: every core, every device, the RAM, the display's GPU memory and the shared folders' files. Restoring it continues exactly where it stopped.
Two kinds, as in QEMU:
savevm | migrate to a file | |
|---|---|---|
| Saved in | The host's snapshot store, by name | A file you name |
| Restore with | loadvm TAG, or -loadvm TAG at launch | A new machine with the same command line plus -incoming file:PATH |
| Machine after saving | Keeps running | Paused (postmigrate) |
savevm and loadvm
(wemu) savevm before-upgrade
(wemu) info snapshots
(wemu) loadvm before-upgrade
(wemu) delvm before-upgradeFrom code, through the monitor or QMP's snapshot jobs:
await vm.hmp("savevm before-upgrade");
await vm.qmp("snapshot-load", { "job-id": "load1", tag: "before-upgrade" });Where snapshots are kept
The host's snapshot store decides. By default it's memory, for as long as the machine exists.
- In Node: keep them as files with
nodeWEMUHost({ snapshotDir: "./snapshots" }), and start a new machine from one with-loadvm TAG. - In a browser: give the host a
snapshotsstore backed by IndexedDB or OPFS.
Note The wemu-system-aarch64 command keeps savevm snapshots in memory only: they're gone when it exits, and -loadvm finds nothing. To keep a state across runs from the command line, use migrate to a file.
Saving to a file
await vm.qmp("migrate", { uri: "file:state.bin" });Then start a machine with the same command line plus -incoming:
wemu-system-aarch64 <same options> -incoming file:state.binOr start it with -incoming defer and load the state when you're ready with migrate-incoming.
What's included
- Every core, the interrupt controller, the timers and every device's state.
- RAM, compressed: blocks the guest never wrote are skipped.
- Disks held in memory (with
snapshot=on, or in the stock browser host). - The shared folders' files.
- With a display: the GPU's memory, every texture and buffer, and the screen.
Not included: disks opened in place. Their bytes are already in their files. Restore on a machine that opened the same disk files, unchanged since the snapshot.
Size and speed
Measured on an Apple M3:
| Machine | Save | Size |
|---|---|---|
| 1 GiB of RAM, after booting Alpine | 0.15 s | 34 MiB |
| 8 GiB of RAM | 0.31 s | 73 MiB |
| 1080p display with 3D | 0.4 s | 52 MB |