feat(vm): replace --on-demand with --restore-mode copy|ondemand|mmap#127
Merged
Conversation
CH's restore API takes one memory_restore_mode enum; a bool flag can only reach one of its three values. --restore-mode passes the value through (empty/copy omits the field, preserving the wire default), adding the new mmap mode: CoW-map the snapshot memory file so clones of one snapshot share page cache — measured on 16 cores: 16-way clone burst per-clone p50 450ms -> 79ms vs copy. ondemand/mmap require the snapshot file to remain on disk; mmap additionally requires it unchanged for the VM lifetime. --on-demand is removed rather than aliased: it mapped to the same field and CH-side gains nothing from a second spelling.
An older CH has no memory_restore_mode field and serde silently ignores it, restoring by copy while reporting success; say so instead of gating restore on a version probe the clone hot path would have to pay for.
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.
What
Replaces the bool
--on-demandflag onvm clone/vm restorewith--restore-mode copy|ondemand|mmap, passed straight through to Cloud Hypervisor'smemory_restore_moderestore field.--on-demandis removed rather than aliased: it mapped to the same single CH enum field, and a second spelling buys nothing.copyomits the field (wire behavior identical to before — old CH binaries unaffected).ondemand→OnDemand(UFFD lazy restore, unchanged semantics).mmap→Mmap(new CH mode, vmm: add mmap memory restore mode cloud-hypervisor#1): CoW-maps the snapshot memory file so clones of one snapshot share page cache. Measured on 16 cores: 16-way clone burst per-clone p50 450ms → 79ms vs copy.--on-demand(flag help says CH only).types.VMConfig.OnDemand bool→RestoreMode string, still transient (json:"-"), never persisted.Evidence
make lintdual-platform 0 issues;go test -race ./...28 pkgs ok; new table test for the flag validation.--restore-mode mmapclone boots + exec ✓, default copy ✓,--restore-mode ondemandclone via UFFD ✓, invalid value rejected at parse ✓,--on-demandnow unknown flag ✓,vm restore --restore-mode mmapafter stop ✓.Note:
mmap/ondemandrequire the snapshot file to remain on disk for the VM lifetime;mmapadditionally requires it unchanged (documented in the CH PR).