Tags: cocoonstack/cloud-hypervisor
Tags
vmm: add diff snapshots Every snapshot currently dumps the entire guest RAM, so the pause a snapshot imposes grows with the memory size regardless of how little the guest has changed. Iterative checkpointing and warm pre-copy (take a snapshot, let the guest run, take another) repeat that full-memory cost every round. Add a diff snapshot: `vm.snapshot` accepts a `snapshot_type` of `full` (default) or `diff`, exposed as `ch-remote snapshot --diff`. The first diff of a series writes a full baseline and enables dirty-page tracking; each subsequent diff dumps only the pages dirtied since the previous one, so its pause is proportional to the dirtied memory rather than to the guest RAM size. Dirty pages are harvested after the device snapshot, so pages touched by snapshot side effects are included. They are written as a sparse `memory-ranges.diff` whose extents sit at the same offsets as in the baseline `memory-ranges`, so a delta applies onto the baseline without translation. A full snapshot, a memory layout change, a migration, restore, or deleting the VM ends the series; the next diff starts a new one. Restore takes the chain directly: `vm.restore` accepts `memory_chain`, the ancestor snapshot URLs oldest first, with `source_url` pointing at the newest delta. Memory fills from the baseline, then every delta's dirty extents replay in order through the same SEEK_DATA walk the eager restore already uses; device state and config come from the newest delta as before. A delta whose length does not match the restored layout is rejected before any page is touched, a filesystem that cannot report extents fails the restore rather than zeroing undirtied pages, and `memory_chain` is incompatible with `memory_restore_mode=ondemand`. Dirty tracking is enabled lazily on the first diff rather than at boot, so a VM that never takes a diff snapshot pays no runtime cost. Validated: an integration test writes tmpfs markers before and after the baseline and reads both back through a chain restore; unit tests cover extent replay over holes and the layout-length check. On a three-phase workload that dirtied one phase between snapshots, the diff pause measured ~17x shorter than the full one. Signed-off-by: CMGS <ilskdw@gmail.com>