Repository navigation
fix(cloudhypervisor): a Windows clone or restore resumes from the snapshot's clock - #341
Merged
CMGS merged 2 commits intoNov 27, 2026
Merged
Conversation
CMGS
marked this pull request as ready for review
November 27, 2026 17:08
…pshot's clock Cloud Hypervisor advances the guest clock by the snapshot's age on restore, which moves a Windows guest's uptime forward by the same amount. When that jump is 2^31 to 2^32 ms (24.9 to 49.7 days), the guest can resume with its TCP retransmission timers stopped (cocoonstack/cloud-hypervisor#9). Send clock_catchup=false with vm.restore for a Windows clone and restore. The guest's date is then behind by the snapshot's age until something sets it in the guest. A migration receive still catches up, and a Cloud Hypervisor without the option ignores the field.
…oud Hypervisor has now The clock_catchup field this branch sent is gone: upstream took the same idea as clock_restore_mode (advance or preserve) and the fork dropped its patch for it, so the field was ignored and a Windows restore advanced the clock as before. One function, restoreClockMode, owns the rule for both call sites: a Windows clone and a Windows restore preserve, a migration receive and every Linux guest keep the default. vm clone prints the Set-Date step with its other Windows hints, and the test moves next to the other restoreAndResumeClone tests.
CMGS
force-pushed
the
windows-restore-keep-clock
branch
from
November 27, 2026 17:18
1c90d04 to
2402701
Compare
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
cocoon vm cloneandcocoon vm restoresend"clock_restore_mode": "Preserve"in thevm.restorerequest for a Windows guest. The guest then resumes from the snapshot's clock: its uptime continues from the snapshot, and its date and time are behind by the snapshot's age until something sets them in the guest.vm migratereceive keeps the default too: the gap is the seconds of the handoff, and advancing keeps the guest's date right.vm cloneprints theSet-Datestep with its other Windows hints. docs/windows.md has the section.Why
A Windows guest restored with the default moves its uptime forward by the snapshot's age. When that jump is 2^31 to 2^32 ms (24.9 to 49.7 days) the guest can come back unable to retransmit TCP: it sends a segment once and never again (cocoonstack/cloud-hypervisor#9). The guest looks healthy otherwise, so the failure is silent, and a snapshot taken from such a guest hands the fault to its clones. A date that is behind fails loudly (TLS) and one command in the guest fixes it.
Changes against the first version of this PR
clock_catchup: false, the option of vmm: Add clock_catchup to the restore config cloud-hypervisor#10. Upstream has since taken the same idea asclock_restore_mode(AdvanceorPreserve), and the fork dropped its own patch when it rebased on 2026-11-27. On the currentdevbuild the old field is ignored, so the first version changed nothing there. Both clearKVM_CLOCK_REALTIMEbeforeKVM_SET_CLOCKand skip the TSC advance, so the mechanism the original evidence measured is the one this version asks for.restoreClockMode(vmCfg, migrationReceive)decides for both call sites;restoreVMtakes the mode. The first version had a*boolfield, a forwarder overvmCfg.Windowsand the migration exception spelled at one call site.restoreAndResumeClonetests.The decision this PR makes
Windows guests always preserve; there is no flag. The first version asked whether this should be opt-in, or whether cocoon should set the date through the guest agent.
Set-Date. It needs a control-plane step it did not need before.For downstream
Requirements
A Cloud Hypervisor that knows
clock_restore_mode: upstream from 2026-11-23, the cocoonstackdevbuild from v56.0.0-dev-5fd961f7. An older one ignores the field and advances the clock, as today.Size and cost
utils.go+17 / -2 (the mode type and constant, the field,restoreClockMode),clone.goandrestore.goone changed line each,clonehints.go+4.vm.restorebody. No added call, no added wait.Gates: golangci-lint 0 issues on linux and darwin, fmt, vet,
go mod tidy -diff, asl on both;go test -raceon darwin (39 packages) and in a linux container (40 packages).Coverage
Hardware for the rows marked so: bare metal, x86_64, kernel 6.12; Cloud Hypervisor from the cocoonstack
devbuild v56.0.0-dev-5fd961f7; Windows 11 25H2, 2 vCPU / 4G, no NIC, read over vsock exec. Candidate is this branch (2402701), control is master (b780388). The contrasts and thresholds were written down before the run: 31 checks, 0 failures.vm cloneprinted theSet-Datestep, and after it the guest was 2 s from the hostvm restoreto the same snapshotvm hibernate, 300 s, wake byvm restorevm.restorebody: Linux clone, Windows clone, Windows migration receive"Preserve", no fieldSet-Datestep; Linux hints do notclock_catchup=falseon v0.7.1Preservestate.json, so it skipped the cellvm migrate