Thanks to visit codestin.com
Credit goes to github.com

Skip to content

vmm: restore KVM clock before resuming vCPUs - #7932

Merged
rbradford merged 1 commit into
cloud-hypervisor:mainfrom
cocoonstack:fix/resume-clock-ordering
Mar 31, 2026
Merged

rbradford merged 1 commit into
cloud-hypervisor:mainfrom
cocoonstack:fix/resume-clock-ordering

Conversation

@CMGS

@CMGS CMGS commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

The resume() method previously started vCPUs before calling KVM_SET_CLOCK, causing guests to execute with stale clock parameters. This is particularly problematic for Windows/Hyper-V guests where the TSC reference page contains outdated scale/offset values, leading to ~4 minute hangs after vm.restore.

Reorder resume() to: set_clock → device_manager.resume → cpu_manager.resume. This matches the inverse of pause() which correctly saves the clock before pausing vCPUs.

close #7930

@CMGS
CMGS requested a review from a team as a code owner March 31, 2026 06:23

@phip1611 phip1611 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Let me run this through our pipeline.

LGTM but I want to make sure it's working reliably

@CMGS
CMGS force-pushed the fix/resume-clock-ordering branch from c2af4bd to c2324b3 Compare March 31, 2026 06:27
Comment thread vmm/src/vm.rs

@phip1611 phip1611 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Please address the remaining remarks

Comment thread vmm/src/vm.rs
@phip1611

Copy link
Copy Markdown
Member

Please check our contribution guidelines (CONTRIBUTING.md). Your commit message should be no longer than 72 chars. Please wrap it!

@CMGS
CMGS force-pushed the fix/resume-clock-ordering branch from c2324b3 to 477d212 Compare March 31, 2026 06:39
@CMGS

CMGS commented Mar 31, 2026

Copy link
Copy Markdown
Contributor Author

@phip1611 thanks for your commnets, first time contribute to this hh, already wrap the commit logs and remove the empty line

@CMGS
CMGS force-pushed the fix/resume-clock-ordering branch from 477d212 to 4f39cdb Compare March 31, 2026 06:48
@phip1611

Copy link
Copy Markdown
Member

We think we've seen this bug also in production - nice find!

Reorder resume() to: set_clock, device_manager.resume,
cpu_manager.resume. This matches the inverse of pause()
which correctly saves the clock before pausing vCPUs.

Signed-off-by: CMGS <[email protected]>
@CMGS
CMGS force-pushed the fix/resume-clock-ordering branch from 4f39cdb to 62bac4c Compare March 31, 2026 06:57

@rbradford rbradford left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks! - i've also been investigating clock issues after a pause/resume. Not sure if this is the same issue but the fix lgtm!

@rbradford
rbradford enabled auto-merge March 31, 2026 07:06
phip1611 pushed a commit to phip1611/cloud-hypervisor that referenced this pull request Mar 31, 2026
Backport [0].

Reorder resume() to: set_clock, device_manager.resume,
cpu_manager.resume. This matches the inverse of pause()
which correctly saves the clock before pausing vCPUs.

[0] cloud-hypervisor#7932

Signed-off-by: CMGS <[email protected]>
@rbradford
rbradford added this pull request to the merge queue Mar 31, 2026
Merged via the queue into cloud-hypervisor:main with commit ff20f18 Mar 31, 2026
38 checks passed
tpressure pushed a commit to cyberus-technology/cloud-hypervisor that referenced this pull request Mar 31, 2026
Backport [0].

Reorder resume() to: set_clock, device_manager.resume,
cpu_manager.resume. This matches the inverse of pause()
which correctly saves the clock before pausing vCPUs.

[0] cloud-hypervisor#7932

Signed-off-by: CMGS <[email protected]>
@CMGS
CMGS deleted the fix/resume-clock-ordering branch April 1, 2026 02:18
Coffeeri added a commit to Coffeeri/cloud-hypervisor that referenced this pull request Apr 10, 2026
Since we backported the resume ordering from upstream PR cloud-hypervisor#7932 in
cyberus PR cloud-hypervisor#133, virtio devices resume before vCPUs.

Some devices need follow-up work that may notify the guest and must
therefore wait until vCPUs are running again.

We add a post-vCPU-resume virtio callback and invoke it after
CpuManager::resume() completes.

This callback will be used in a follow-up commit which drains the
virtio-blk queue once the vCPUs are resumed after a restore.

Ref: cloud-hypervisor#7932
Ref: cyberus-technology#133

On-behalf-of: SAP [email protected]
Signed-off-by: Leander Kohler <[email protected]>
Coffeeri added a commit to cyberus-technology/cloud-hypervisor that referenced this pull request Apr 10, 2026
Since we backported the resume ordering from upstream PR cloud-hypervisor#7932 in
cyberus PR #133, virtio devices resume before vCPUs.

Some devices need follow-up work that may notify the guest and must
therefore wait until vCPUs are running again.

We add a post-vCPU-resume virtio callback and invoke it after
CpuManager::resume() completes.

This callback will be used in a follow-up commit which drains the
virtio-blk queue once the vCPUs are resumed after a restore.

Ref: cloud-hypervisor#7932
Ref: #133

On-behalf-of: SAP [email protected]
Signed-off-by: Leander Kohler <[email protected]>
@rbradford rbradford moved this to ✅ Done in Cloud Hypervisor Roadmap Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

vm.resume starts vCPUs before KVM clock is restored, causing ~4 minute hang for Windows/Hyper-V guests

3 participants