Skip to content

Commit 6440465

Browse files
vmm_tests: enable nested reboot tests on Windows
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>
1 parent 7a9e12e commit 6440465

4 files changed

Lines changed: 29 additions & 3 deletions

File tree

‎openvmm/openvmm_hypervisors/src/lib.rs‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,28 @@ pub fn mshv_partition_scrub_available() -> bool {
8080
}
8181
}
8282

83+
/// Returns whether WHP supports nested partition reset on this machine.
84+
pub fn whp_nested_reset_available() -> bool {
85+
#[cfg(all(
86+
target_os = "windows",
87+
feature = "virt_whp",
88+
guest_is_native,
89+
guest_arch = "x86_64"
90+
))]
91+
{
92+
virt_whp::is_nested_reset_available()
93+
}
94+
#[cfg(not(all(
95+
target_os = "windows",
96+
feature = "virt_whp",
97+
guest_is_native,
98+
guest_arch = "x86_64"
99+
)))]
100+
{
101+
false
102+
}
103+
}
104+
83105
#[expect(clippy::allow_attributes, reason = "lots of conditions")]
84106
#[allow(dead_code)]
85107
pub(crate) fn parse_bool_param(key: &str, val: &str) -> anyhow::Result<bool> {

‎petri/src/requirements.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ impl HostContext {
170170
let nested_reset_supported = match openvmm_hypervisor {
171171
Some(OpenVmmHypervisor::Kvm) => openvmm_hypervisors::kvm_nested_state_available(),
172172
Some(OpenVmmHypervisor::Mshv) => openvmm_hypervisors::mshv_partition_scrub_available(),
173+
Some(OpenVmmHypervisor::Whp) => openvmm_hypervisors::whp_nested_reset_available(),
173174
_ => false,
174175
};
175176

‎vmm_core/virt_whp/src/lib.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,12 @@ pub fn is_available() -> Result<bool, Error> {
971971
whp::capabilities::hypervisor_present().for_op("query hypervisor presence")
972972
}
973973

974+
/// Returns whether WHP can reset partitions with nested virtualization enabled.
975+
#[cfg(guest_arch = "x86_64")]
976+
pub fn is_nested_reset_available() -> bool {
977+
whp::capabilities::reset_partition()
978+
}
979+
974980
/// The prototype partition.
975981
pub struct WhpProtoPartition<'a> {
976982
vtl0: VtlPartition,

‎vmm_tests/vmm_tests/tests/tests/nested.rs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33

44
//! Nested vm host definitions
55
6-
#[cfg(target_os = "linux")]
76
use anyhow::Context as _;
87
use petri::PetriVmBuilder;
98
#[cfg(target_os = "linux")]
109
use petri::PetriVmmBackend;
1110
use petri::openvmm::OpenVmmPetriBackend;
12-
#[cfg(target_os = "linux")]
1311
use petri_artifacts_vmm_test::artifacts::host_tools::NEXTEST_VMM_TESTS_ARCHIVE_LINUX_X64_MUSL;
1412

1513
pub(crate) async fn vm_host(config: PetriVmBuilder<OpenVmmPetriBackend>) -> anyhow::Result<()> {
@@ -151,7 +149,6 @@ async fn reboot_nested_virt(config: PetriVmBuilder<OpenVmmPetriBackend>) -> anyh
151149

152150
/// Reboot a Linux L2 three times. The `reboot_l1` variant reruns this after
153151
/// rebooting L1, proving L2 can launch after previously used nested state resets.
154-
#[cfg(target_os = "linux")]
155152
#[vmm_test_macros::vmm_test(
156153
nested(
157154
(vm_host, openvmm_linux_direct_x64),

0 commit comments

Comments
 (0)