Skip to content

kvm: mshv: Add vmm test cases to validate reset and fix for KVM on nested - #5085

Merged
Muminul Islam Russell (russell-islam) merged 8 commits into
microsoft:mainfrom
russell-islam:muislam/nested-reboot-tests
Nov 21, 2026
Merged

Muminul Islam Russell (russell-islam) merged 8 commits into
microsoft:mainfrom
russell-islam:muislam/nested-reboot-tests

Conversation

@russell-islam

Copy link
Copy Markdown
Contributor

Add a VMM test case for verifying reboot on Linux nested scenario and fix the reboot for KVM case.

Copilot AI balanced review requested due to automatic review settings November 13, 2026 22:09
@github-actions github-actions Bot added Guide unsafe Related to unsafe code labels Nov 13, 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.

🟡 Changes recommended

The test’s nested-virtualization requirement selects MSHV hosts without scrub support, causing reset failures unless selection is gated on nested-reset support or restricted to KVM.

1 open issue
What changed in this PR

Adds regression coverage for rebooting nested-enabled Linux guests and fixes KVM’s handling of nested virtualization state during reset.

Changes:

  • Reset inactive VMX or SVM state through KVM_SET_NESTED_STATE, with unit tests for the reset headers.
  • Add a two-CPU guest test that reboots three times and verifies connectivity, boot identity, and virtualization flags.
  • Document how to run the test and the KVM/MSHV prerequisites.
File Description
vmm_tests/​vmm_tests/​tests/​tests/​nested.rs Adds repeated reboot coverage for nested-enabled Linux guests.
vmm_core/​virt_kvm/​src/​arch/​x86_64/​vp_state.rs Handles empty nested state as a KVM reset request.
vm/​kvm/​src/​lib.rs Adds the nested-state reset ioctl wrapper, reset headers, and unit tests.
Guide/​src/​dev_guide/​tests/​vmm.md Documents test execution, backend requirements, and coverage limits.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 13, 2026 23:56
@github-actions

Copy link
Copy Markdown

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.

🟡 Changes recommended

The KVM requirement advertises nested_reset without checking KVM_CAP_NESTED_STATE, causing the new test to fail rather than skip on unsupported hosts.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread petri/src/requirements.rs Resolved
@github-actions

Copy link
Copy Markdown

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.

🔵 Needs a closer look

Vendor-specific KVM reset semantics and the new MSHV scrub probe require hardware-backed reboot and compatibility validation that was unavailable in this review.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@github-actions

Copy link
Copy Markdown

Comment thread vmm_core/virt_mshv/src/lib.rs Resolved
Comment thread petri/src/requirements.rs Resolved
Comment thread petri/src/requirements.rs Resolved
Comment thread vm/kvm/src/lib.rs Resolved
Comment thread Guide/src/dev_guide/tests/vmm.md Resolved
Comment thread Guide/src/dev_guide/tests/vmm.md Resolved
Comment thread vm/kvm/src/lib.rs Resolved
Copilot AI balanced review requested due to automatic review settings November 16, 2026 20:27
/// Reboot a two-VP Linux L1 three times with nesting enabled and VMBus disabled.
/// Check changed boot IDs, connectivity, and VMX/SVM exposure on both VPs.
/// This does not launch an L2; `reboot_l2` separately exercises an L2 reboot.
#[cfg(target_os = "linux")]

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.

Why is this limited to Linux?

@russell-islam Muminul Islam Russell (russell-islam) changed the title Reboot tests and fix for KVM on netsed kvm: mshv: Add vmm test cases to validate reset and fix for KVM on netsed Nov 17, 2026
@github-actions

Copy link
Copy Markdown

}

/// Run the L2 test before and after an L1 reboot to exercise used nested state.
#[cfg(target_os = "linux")]

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.

Still waiting for the Linux host cfgs to go away and for WHP to be tagged as supporting the new required feature.

@github-actions

Copy link
Copy Markdown

@russell-islam
Muminul Islam Russell (russell-islam) force-pushed the muislam/nested-reboot-tests branch 2 times, most recently from 27370c1 to b29d023 Compare November 18, 2026 03:20
@jstarks

Copy link
Copy Markdown
Member

The Linux host restrictions haven't been fully removed yet:

  • reboot_l1 is now unconditional and calls .with_context(), but use anyhow::Context as _ is still Linux-only. This leaves the Windows test build without the required trait import.
  • reboot_l2 still has #[cfg(target_os = "linux")], so neither nested reboot variant is registered on Windows. The NEXTEST_VMM_TESTS_ARCHIVE_LINUX_X64_MUSL import also needs to be available there—the archive runs inside the Linux L1, regardless of the host OS.
  • reboot_nested_virt requires nested_reset, but HostContext::new() only enables that capability for KVM/MSHV and returns false for WHP. Even after fixing compilation, this test will still skip on Windows unless PETRI_CAPABILITIES overrides it.

Could you finish removing these host restrictions and report nested-reset support appropriately for WHP? The Linux guest configurations and /proc checks can stay; those don't restrict the host OS.

@jstarks John Starks (jstarks) changed the title kvm: mshv: Add vmm test cases to validate reset and fix for KVM on netsed kvm: mshv: Add vmm test cases to validate reset and fix for KVM on nested Nov 18, 2026
@russell-islam
Muminul Islam Russell (russell-islam) force-pushed the muislam/nested-reboot-tests branch 5 times, most recently from 6440465 to 77e4116 Compare November 19, 2026 22:51
Reset empty nested state with KVM_SET_NESTED_STATE for VMX and SVM.
Keep nested save/restore unsupported. Add reset-header unit tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Muminul Islam <muminul.islam@microsoft.com>
Reboot a two-VP guest three times with nesting enabled. Check boot IDs,
agent connectivity, and VMX/SVM flags. Document KVM/MSHV prerequisites.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Muminul Islam <muminul.islam@microsoft.com>
Probe MSHV partition scrub support and require nested_reset.
Skip unsupported hosts while surfacing unexpected probe errors.

Validated capability tests and KVM/MSHV guest reboots.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Muminul Islam <muminul.islam@microsoft.com>
Require KVM_CAP_NESTED_STATE before advertising nested_reset.
Cover unsupported KVM hosts and preserve MSHV scrub gating.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Muminul Islam <muminul.islam@microsoft.com>
Simplify nested-reset discovery and keep backend probes infallible.
Clarify reset-only state handling and trim redundant tests and docs.
Add separate L2 reboot coverage using the nested test infrastructure.

Validated all three reboot tests on KVM and MSHV.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Muminul Islam <muminul.islam@microsoft.com>
Run an L2 before and after rebooting L1 to exercise used nested state.
Gate the L1 wrapper on nested-reset support and keep per-run logs.

Validated all three nested reboot tests on KVM and MSHV.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Muminul Islam <muminul.islam@microsoft.com>
Remove the Linux-only guard from the nested-enabled reboot test.
Note when the MSHV scrub capability probe can be removed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Muminul Islam <muminul.islam@microsoft.com>
Detect WHP nested reset support using WHvResetPartition availability.
Make the reboot test platform independent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Muminul Islam <muminul.islam@microsoft.com>
@russell-islam
Muminul Islam Russell (russell-islam) merged commit bf35346 into microsoft:main Nov 21, 2026
108 of 109 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Guide unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants