Repository navigation
Description
Describe the bug
A snapshot restore advances the guest clock by the snapshot's age. For a Windows guest that moves its uptime forward by the same amount. When the jump is between 2^31 ms (24.86 days) and 2^32 ms (49.71 days), the guest can resume with its TCP retransmission timers stopped: it sends a segment once and never sends it again.
The guest looks healthy otherwise. Commands through the guest agent answer in under 100 ms, timers on every vCPU fire on time, there is no bugcheck, and the VMM delivers every frame the guest sends (the guest NIC's sent-frame count equals the frames written to the tap). The problem shows when one packet is lost: the connection hangs for good. We found it as an SFTP write to a guest that hung for 12 minutes right after a wake, with the peer's ACK number 80 bytes behind the guest's sequence number and only keepalives on the wire.
Both v54.0.0 and v55.0.0-dev-2ca4cb08c59b do this. The jump comes from with_realtime_filled() at capture and KVM_SET_CLOCK with KVM_CLOCK_REALTIME on restore (upstream 56e891a); dev also advances the TSC by the same amount (71a05f9).
A snapshot taken from an affected guest keeps the state. A golden image built by restoring a 28-day-old base snapshot and snapshotting again gives clones without retransmits, although that second snapshot is an hour old.
To Reproduce
The probe: the guest opens a TCP connection to a blackholed address, and the host counts the SYNs on the VM's tap. A healthy Windows guest sends three, at 0 s, 1 s and 3 s. An affected guest sends one.
# in the guest
$c = New-Object Net.Sockets.TcpClient
$r = $c.BeginConnect('192.0.2.1', 8300, $null, $null)
[void]$r.AsyncWaitHandle.WaitOne(5500); $c.Close()# on the host, in the VM's network namespace, while the guest command runs
tcpdump -ni <tap> 'tcp dst port 8300 and tcp[tcpflags] & tcp-syn != 0'- Take a snapshot of a Windows 10 guest. Ours was taken 162 s after boot.
- Restore it 25 to 49 days later with a plain
vm.restoreandvm.resume(cocoon vm clone --restore-mode copy). - The guest's uptime (
Win32_PerfFormattedData_PerfOS_System.SystemUpTime) is the snapshot's age. Run the probe: one SYN.
To change the age without waiting, move the saved realtime back in a copy of the snapshot's state.json. It is bytes 16 to 23 of the Kvm array under clock, little-endian nanoseconds. This is how the 47.05-day and 50.05-day rows below were made.
The age is not sufficient by itself, and we have not found the other condition. A snapshot of a freshly cold-booted guest restored as 20, 24.5, 25.2, 49.5 and 50 days old retransmitted normally all five times. What the guest was doing when the snapshot was taken matters. The snapshots that do reproduce it have done so on every restore.
Evidence
All rows are fresh restores on x86_64 KVM hosts, probed once the guest agent answered. "Old" is v54.0.0, "new" is v55.0.0-dev-2ca4cb08c59b.
| Guest and snapshot | Clock jump at restore | Old | New |
|---|---|---|---|
| Windows 10, base snapshot A, AMD host | 27.8 to 28.0 days | not run | no retransmits, 4 of 4 |
| Windows 10, golden image built on A the day A was taken, AMD host | 27.05 days | no retransmits, 1 VM | no retransmits, 1 of 1 |
| Windows 10, golden image built when its base was 28.0 days old, restored an hour later, Intel host | 28.0 days, at the build | no retransmits, 3 of 3 | no retransmits, 4 of 4 |
| Windows 10, golden image built when its base was 4.2 days old | 23.8 days | not run | normal, 1 of 1 |
| Windows 10, an older golden image | 50.07 days | not run | normal, 1 of 1 |
| Windows 11 | 65.9 days | normal, 1 of 1 | normal, 3 of 3 |
| Windows Server | 75.9 days | no retransmits, 1 of 6 | no retransmits, 4 of 6 |
| The affected guest of row 2, snapshotted and restored with 20 more days | 47.05 days in total | not run | no retransmits, 1 of 1 |
| The same with 23 more days | 50.05 days in total | not run | normal, 1 of 1 |
| A VM that slept 25.17 days | 25.17 days | no retransmits, 1 VM | not run |
| A VM that slept 19.1 days | 19.1 days | not run | normal, 1 VM |
- The upper edge is measured: the same guest has no retransmits at 47.05 days and normal ones at 50.05 days.
- The lower edge has two points: normal at 23.8 days, no retransmits at 25.17 days.
- Windows Server at 75.9 days is intermittent, which a single 32-bit wrap does not explain. 75.9 days is 26.2 days past one wrap.
Restoring without the jump avoids it. On a private copy of base snapshot A at 27.8 to 28.0 days, alternating:
| Restore | Guest uptime after restore | Probe |
|---|---|---|
Unchanged, 2ca4cb08 |
27.78 to 28.02 days | no retransmits, 4 of 4 |
KVM_CLOCK_REALTIME cleared in state.json, 2ca4cb08 |
162 s | normal, 4 of 4 |
| Unchanged, the build from the pull request | 28.02 to 28.03 days | no retransmits, 2 of 2 |
clock_catchup=false, the builds from the two pull requests |
162 s | normal, 4 of 4 |
After a restore without the jump the guest's date is the snapshot's. Set-Date in the guest corrects it and leaves the uptime alone (162 s before, 168 s after), and the probe stays normal.
How we read it, as a guess: Windows' TCP timers compare 32-bit millisecond ticks, so a forward jump of 2^31 to 2^32 ms looks like a step backwards and the timers wait for the clock to come back. Hyper-V does not make this jump: the TLFS says the partition reference time "will appear to stop during the time that a guest partition is saved".
Version
Output of cloud-hypervisor --version: cloud-hypervisor v55.0.0-dev-2ca4cb08c59b and cloud-hypervisor v54.0.0
Did you build from source, if so build command line (e.g. features): no, the dev release build. The build with the fix: cargo build --release --features fw_cfg.
VM configuration
What command line did you run (or JSON config data): VMs created by cocoon v0.7.1 with --windows (kvm_hyperv=on, no balloon), 4 vCPU and 8 GiB (one golden image with 2 vCPU and 4 GiB), one virtio-net on a tap, restored with memory_restore_mode unset (copy).
Guest OS version details: Windows 10 Pro 10.0.19045.2965, tcpip.sys 10.0.19041.2673, netkvm.sys 100.101.104.28500. Also Windows Server, intermittently. Windows 11 was only tested at 65.9 days, outside the range. Linux guests were not probed.
Host OS version details: Ubuntu 24.04, kernel 7.0.0-31, AMD EPYC 7443P. Also reproduced on Intel Emerald Rapids hosts.
Logs
Cloud Hypervisor logs nothing for this, the host kernel logs nothing about KVM, and the guest records no error.
Proposed fix
A restore option that leaves the guest clock at its saved value, used by cocoon for Windows guests: #10 and cocoonstack/cocoon#341.
Activity
hypervisor: Add a clock restore mode without catch-up
vmm: Add clock_catchup to the restore config
vmm: Add clock_catchup to the restore config
vmm: Add clock_catchup to the restore config
CMGS commentedon Nov 23, 2026
Fixed on dev by 02e5f0d ("vmm: Add clock_catchup to the restore config", the squash of #10), released as v56.0.0-dev-015ba3288c2a. A restore with
clock_catchup=offcontinues the guest clock from the snapshot. Tested on hardware: with a 125 s gap, guest uptime moved 4 s instead of 125 s. The two original commits are kept on theclock-catchupbranch.vmm: Add clock_catchup to the restore config
hypervisor: Add a clock restore mode without catch-up
vmm: Add clock_catchup to the restore config