Skip to content

virt_mshv: freeze partition time across restore - #4477

Open
ayusharora221204 wants to merge 1 commit into
microsoft:mainfrom
ayusharora221204:user/ayusharora/mshv-restore-time-freeze
Open

ayusharora221204 wants to merge 1 commit into
microsoft:mainfrom
ayusharora221204:user/ayusharora/mshv-restore-time-freeze

Conversation

@ayusharora221204

@ayusharora221204 ayusharora221204 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

The Microsoft hypervisor requires partition time to be explicitly frozen (via HV_PARTITION_PROPERTY_TIME_FREEZE) before the reference time can be modified. During snapshot restore, restore_all() calls the MSHV set_reftime() path without first freezing partition time. Without this, HvCallSetPartitionProperty for reference time returns HV_STATUS_INVALID_PARTITION_STATE (0x7), causing restore to fail.

Freeze partition time in set_reftime() before restoring ReferenceTime. The existing freeze operation is idempotent, so the reset path remains unchanged, and time is still thawed lazily by the first VP to enter run_vp. This keeps time frozen through the remaining VM and per-VP state restoration rather than thawing immediately after the property write.

Freeze MSHV partition time before restoring ReferenceTime and retain the existing lazy thaw on first VP execution so the remaining VM and VP timer state is restored consistently.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f9c48f8e-125f-4bf9-a741-3850a89fd5ba
@ayusharora221204
ayusharora221204 requested a review from a team as a code owner September 17, 2026 17:51
Copilot AI lite review requested due to automatic review settings September 17, 2026 17:51
@github-actions github-actions Bot added the unsafe Related to unsafe code label Sep 17, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No unresolved review issues were identified.

Pull request overview

Updates MSHV snapshot restoration to freeze partition time before restoring ReferenceTime, preserving lazy thaw behavior.

Changes:

  • Freeze partition time before setting ReferenceTime.
  • Document restore-related freeze/thaw behavior.
File summaries
File Description
vmm_core/virt_mshv/src/x86_64/vm_state.rs Freezes time before setting reference time.
vmm_core/virt_mshv/src/lib.rs Documents restore-related freeze behavior.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants