Skip to content

Select the OpenVMM backend and port OpenVMM test infrastructure - #42315

Draft
Daman Mulye (damanm24) wants to merge 7 commits into
feature/openvmmfrom
user/damanmulye/openvmm-test-fixes
Draft

Daman Mulye (damanm24) wants to merge 7 commits into
feature/openvmmfrom
user/damanmulye/openvmm-test-fixes

Conversation

@damanm24

@damanm24 Daman Mulye (damanm24) commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Follow-up to #42246. Ports backend selection and the testing and CI changes from the OpenVMM integration branch to feature/openvmm:

  • experimental.openVmm=true now creates the VM with the OpenVMM backend, with the wiring WSL needs to run on it.
  • Test infrastructure for running the WSL2 suite against the OpenVMM backend (/p:OpenVmm=1).
  • A dedicated wsl2-openvmm CloudTest pass.
  • OpenVMM-mode adjustments to the existing WSL test suites.
  • New OpenVMM backend tests, adapted to the backend as merged in Port initial OpenVMM integration work #42246.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Backend selection

  • WslCoreVm creates the VM with CreateVirtualMachineBackend(), using OpenVMM when experimental.openVmm=true.
  • Memory features and the hosting-process name suffix are requested from the selected backend's capabilities. The guest DMA window is configured only when the backend supports it.
  • Networking: OpenVMM NAT adds its eth0 NIC (with the configured or generated MAC) and, with localhost forwarding, its loopback0 NIC at creation, then runs OpenVmmNatNetworking. HNS NAT networks are created only for HCS, and the guest isn't asked for the DNS tunneling hvsocket on OpenVMM.
  • Guest connections: process launch, the root-namespace processes, distro import/export and the instance ports connect through IVirtualMachineBackend::ConnectGuest. CreateLxProcess returns a serialized GuestConnector, which wsl.exe and wslhost.exe use for interop instead of the VM ID. The relays handle the AF_UNIX connections OpenVMM uses.
  • File systems:
    • DrvFs uses virtio-fs only on OpenVMM, with the token checks it needs to impersonate the session.
    • Plugin folder mounts use single-share virtio-fs devices.
    • Read-only virtio-fs shares are enforced by the host.
    • DetachDisk matches paths before reopening a VHD that the backend holds exclusively.
  • Console pipes (dmesg, guest telemetry, kernel debugger) grant the user access, because the OpenVMM process runs as the user. The kernel console uses virtio console on OpenVMM.
  • OpenVMM captures saved state into the crash dump folder.

Left out of the integration branch's WslCoreVm changes:

Test infrastructure

  • LxsstuOpenVmmMode() reads /p:OpenVmm=1. When it is set, LxssGenerateTestConfig() writes experimental.openVmm=true and defaults the settings OpenVMM doesn't support: no GUI apps or GPU, virtio-fs drvfs with single-share devices, and no nested virtualization.
  • New test markers:
    • OPENVMM_UNSUPPORTED_TEST_CLASS / OPENVMM_UNSUPPORTED_WSL2_TEST_METHOD skip tests under OpenVMM.
    • OPENVMM_TEST_CLASS tags tests that drive the OpenVMM backend directly.
    • BACKEND_AGNOSTIC_TEST_CLASS tags tests whose result can't depend on the VM backend.
  • Under OpenVMM, the generated config also turns off the Hyper-V firewall, DNS tunneling and hardware performance counters, which the service rejects for OpenVMM. DNS tunneling tests are skipped under OpenVMM.
  • TestConfigDefaults gains localhostForwarding and nestedVirtualization.
  • GetBlockDeviceInWsl() also scans /dev/vdX, because OpenVMM attaches disks over virtio-blk.
  • GetElevatedTestToken() moves to VirtualMachineBackendTestHelpers.h so both backend test suites can use it.

CloudTest

  • Every existing WSL1/WSL2 group now excludes @TestCategory='OpenVMM'.
  • A new wsl2-openvmm group runs the WSL2 suite on rs_prerelease-2026-10-05 with /p:OpenVmm=1, minus BackendAgnostic tests, and adds a backend dimension to the test job names.

WSL test suites

  • The following are skipped under OpenVMM, with a reason at each skip:
    • SCSI-specific mount tests
    • Plan 9, Mirrored and Bridged
    • Hyper-V firewall
    • HNS NAT range persistence
    • GUI-dependent tests
    • sparse VHDs
    • dmesg collection
  • Consommé tests run in NAT mode under OpenVMM.
  • DNS tunneling expects the Consommé gateway as the DNS server.
  • The VM process is openvmm.exe instead of vmmem.
  • Expected error codes include the OpenVmm context.
  • .wslconfig warning line numbers are computed instead of hard-coded.
  • The localhost relay test polls with a timeout instead of possibly blocking forever.
  • The fstab test identifies the C: virtio-fs mount through /run/wsl/virtiofs instead of the tag name.

OpenVMM backend tests

New tests, adapted to the merged backend contracts: the OpenVmm context name, callers adding CreateVm/ConfigureNetworking, VmVirtioBlkAddress slots, and host-socket files removed on destruction.

  • error attribution for creation and operations
  • the nested-virtualization user error
  • creation-time NAT adapters
  • crash-capture validation
  • virtio-blk boot disk reattach
  • the destructor draining the termination callback
  • persistent-memory ordering
  • host-socket lifetime
  • serving a share under an unelevated token from an elevated VM

Not ported, because they were superseded during the #42246 review:

  • tests consolidated into existing tests: ReservesExactPlacementsBeforeAutomaticDisks, LeavesVirtualDiskFileNamesToBackend, EnforcesDiskLimitsAndKeepsIdsVmScoped, DescribesConsoleFamiliesIndependently
  • GuestShutdownTerminatesProcess, covered by NotifiesWhenGuestExits
  • GuestShutdownCallbackCanDestroyBackend, which contradicts the interface rule that termination callbacks must not destroy the backend inline
  • SelectsBackendFromExperimentalFlag, because SelectVirtualMachineBackendKind was removed as unused in Port initial OpenVMM integration work #42246

Validation Steps Performed

  • cmake --build . -- -m (full solution, Debug x64): passed.
  • clang-format --dry-run --Werror on all changed C/C++ files (VS 2022 LLVM): passed.
  • Ran cloudtest/CMakeLists.txt in CMake script mode (cmake -P): each existing WSL group excludes OpenVMM and wsl2-openvmm is generated with /p:OpenVmm=1 and the BackendAgnostic exclusion.
  • Not run locally: the TAEF suites, including the new OpenVMM backend tests, and an end-to-end WSL session on OpenVMM. Test setup reinstalls WSL on the host, so validation relies on the CloudTest passes, with wsl2-openvmm covering OpenVMM end to end.

Adds the /p:OpenVmm=1 test switch and OpenVMM test markers, a dedicated wsl2-openvmm CloudTest pass, OpenVMM-mode adjustments to the WSL test suites, and new OpenVMM backend tests adapted to the merged backend.
@damanm24
Daman Mulye (damanm24) requested a review from a team as a code owner November 20, 2026 17:45
Copilot AI balanced review requested due to automatic review settings November 20, 2026 17:46
@damanm24
Daman Mulye (damanm24) marked this pull request as draft November 20, 2026 17:49

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

Critical blockers remain: OpenVMM defaults prevent WSL startup, network tests use unsupported DNS settings or incorrect MAC expectations, and the filesystem regression fails on a sharing violation.

5 open issues
What changed in this PR

Ports the test infrastructure and suite adjustments for the OpenVMM integration introduced in #42246. Backend selection remains disabled, so the new suite pass still uses HCS; direct OpenVMM backend tests create their own VMs.

Changes:

  • Adds OpenVMM test parameters, configuration defaults, and test-selection markers.
  • Introduces a dedicated CloudTest pass and backend-specific job names.
  • Adapts existing suites and expands backend lifecycle, resource, and error-validation tests.
File Description
test/​windows/​wsl/​UnitTests.cpp Adjusts backend expectations, GUI checks, and configuration-warning tests.
test/​windows/​wsl/​SimpleTests.cpp Skips sparse-VHD testing under OpenVMM.
test/​windows/​wsl/​PolicyTests.cpp Adds backend-specific policy expectations and class tagging.
test/​windows/​wsl/​Plan9Tests.cpp Excludes Plan 9 tests from OpenVMM runs.
test/​windows/​wsl/​Plan9ProtocolTests.cpp Selects NAT networking for OpenVMM.
test/​windows/​wsl/​NetworkTests.cpp Adapts networking coverage and bounds relay reads with a timeout.
test/​windows/​wsl/​MountTests.cpp Skips unsupported disk cases and recognizes the OpenVMM process.
test/​windows/​wsl/​InstallerTests.cpp Tags installer tests as backend-independent.
test/​windows/​wsl/​DrvFsTests.cpp Adds backend-aware class selection and unsupported-case markers.
test/​windows/​VirtualMachineBackendTestHelpers.h Shares the elevated-token helper between backend suites.
test/​windows/​OpenVmmVirtualMachineBackendTests.cpp Expands direct backend error, lifecycle, disk, and resource tests.
test/​windows/​HcsVirtualMachineBackendTests.cpp Updates capability assertions and test categorization.
test/​windows/​common/​WindowsUpdateTests.cpp Tags update tests as backend-independent.
test/​windows/​common/​StringUnitTests.cpp Tags string tests as backend-independent.
test/​windows/​common/​FilesystemUnitTests.cpp Adds exclusive-file path-resolution coverage and class tagging.
test/​windows/​common/​Common.h Declares backend markers, mode detection, and configuration options.
test/​windows/​common/​Common.cpp Generates OpenVMM defaults and discovers virtio-blk devices.
test/​linux/​unit_tests/​fstab.c Identifies virtio-fs drive mappings through runtime symlinks.
cloudtest/​TestGroup.xml.in Passes backend arguments to TAEF.
cloudtest/​CMakeLists.txt Generates the OpenVMM group and backend-specific filters.
.pipelines/​test-stage.yml Adds the dedicated OpenVMM test job.
.pipelines/​test-job.yml Parameterizes backend names and test-map selection.

Review effort: Balanced

Default.guiApplications = Default.guiApplications.value_or(false);
Default.drvFsMode = Default.drvFsMode.value_or(DrvFsMode::VirtioFs);
Default.virtioFsAggregateShares = Default.virtioFsAggregateShares.value_or(false);
Default.nestedVirtualization = Default.nestedVirtualization.value_or(false);
Comment on lines +250 to +251
TempFile file(GENERIC_READ | GENERIC_WRITE, 0, OPEN_EXISTING, TempFileFlags::None);
const auto result = GetFullPath(file.Path.c_str());
Comment thread test/windows/wsl/NetworkTests.cpp Resolved
Comment on lines 6012 to 6013
// eth0 should have wsldevicehost's default client MAC. Update if that default changes.
VERIFY_ARE_EQUAL(GetMacAddress(L"eth0"), std::wstring(L"00:00:00:00:01:00"));
class PolicyTest
{
WSL_TEST_CLASS(PolicyTest)
BACKEND_AGNOSTIC_TEST_CLASS(PolicyTest)
Creates the VM through the backend selected by experimental.openVmm and wires the OpenVMM backend into WSL: user-mode NAT networking, guest connections for process launch and interop, virtio-fs for DrvFs and plugin mounts, console pipe access for the user-run OpenVMM process, and saved-state crash capture. The OpenVMM test configuration now satisfies the backend's configuration validation.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 17:58
@damanm24 Daman Mulye (damanm24) changed the title Port OpenVMM test infrastructure and test fixes Select the OpenVMM backend and port OpenVMM test infrastructure Nov 20, 2026

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.

Comment on lines +361 to +364
auto backendRequest = GenerateBackendRequest(VmId, backendKind);
{
SlowOperationWatcher slowOperation{"HcsCreateSystem"};
m_backend = HcsVirtualMachineBackend::Create(backendRequest);
SlowOperationWatcher slowOperation{"CreateVirtualMachineBackend"};
m_backend = CreateVirtualMachineBackend(backendKind, backendRequest);
Comment on lines +2875 to +2878
if (LxsstuOpenVmmMode())
{
// Linux drops inbound packets addressed to ::1 on non-loopback interfaces, so OpenVMM NAT can't relay IPv6 loopback.
LogInfo("Skipping IPv6 loopback forwarding on OpenVMM NAT");
Comment thread test/windows/wsl/UnitTests.cpp Resolved
validateWarnings(
L"ipv6=true\nipv6=false",
std::format(L"wsl: Duplicated config key 'wsl2.ipv6' in {}:23 (Conflicting key: 'wsl2.ipv6' in {}:22)\r\n", wslConfigPath, wslConfigPath));
std::format(L"wsl: Duplicated config key 'wsl2.ipv6' in {}:{} (Conflicting key: 'wsl2.ipv6' in {}:{})\r\n", wslConfigPath, line + 1, wslConfigPath, line));
Comment thread test/windows/wsl/UnitTests.cpp Outdated
VERIFY_IS_TRUE(output.find(L"experimental.openVmm=true") != std::wstring::npos);
VERIFY_IS_TRUE(output.find(L"wsl2.nestedVirtualization=true") != std::wstring::npos);
VERIFY_IS_TRUE(output.find(L"wsl2.nestedVirtualization=false") != std::wstring::npos);
VERIFY_IS_TRUE(output.find(L"OpenVmm/ERROR_NOT_SUPPORTED") != std::wstring::npos);
Daman Mulye added 5 commits November 20, 2026 16:18
…ows Hypervisor Platform at install

wsl --install no longer enables the Windows Hypervisor Platform for every user, since OpenVMM is opt-in. Whether OpenVMM can run depends on whether the platform reports a hypervisor, which the optional component's state does not reliably predict, so the backend no longer checks it. When OpenVMM finds no hypervisor, it fails CreateVm with "no hypervisor available", which wslopenvmm translates to ERROR_HV_NOT_PRESENT, and WSL reports a message asking the user to enable virtualization in firmware and the Windows Hypervisor Platform.
The OpenVMM backend accepted a disk or persistent memory token only if it was the VM owner's token instance. The service passes a fresh copy of the caller's token for each request, so every attach that carried a token failed with ERROR_NOT_SUPPORTED, including --mount, distribution import and resize.

OpenVMM opens these files by path as the VM owner, so the token is now ignored, as it was before the check was added. This can over-grant or refuse access when the requester and VM owner differ in elevation, unlike HCS, which grants the VM access as the requester. Attaching disks by handle opened as the requester will close that gap once OpenVMM supports it.
Run an OpenVMM boot in the HCS WSL2 pass of every test image, including images without the Windows Hypervisor Platform, to check that OpenVMM either boots or reports ERROR_HV_NOT_PRESENT rather than failing with an unrelated error. The test logs the platform's installed state, the result, and the reported error. The backend now logs the OpenVMM process exit code when the process exits during CreateVm, so a crash, such as a failed delay load of WinHvPlatform.dll, can be identified.
0.0.3-8 is built from upstream microsoft/openvmm and translates OpenVMM's errors into specific HRESULTs, including ERROR_HV_NOT_PRESENT when no hypervisor is available and Win32 errors reported as OS error codes.
Copilot AI balanced review requested due to automatic review settings November 21, 2026 01:44

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

An unresolved critical authorization flaw lets unelevated callers attach administrator-only disks through an elevated VM owner, alongside OpenVMM test failures and CI coverage gaps.

10 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Run nonzero swiotlb success cases only under HCS

test/​windows/​wsl/​UnitTests.cpp:2561

With OpenVMM selected, the preceding positive swiotlb=64M and swiotlb=4096K cases cannot launch echo ok: ValidateOpenVmmSupport rejects both nonzero values. Run those success cases only under HCS, while retaining this malformed-value parser case for both backends.

1 resolved since last review

Review effort: Balanced

Comment on lines +869 to +872
// OpenVMM opens the disk by path as the VM owner, so Request.UserToken isn't used. Unlike HCS, which grants the VM access
// as the requester, this lets a requester attach any file the VM owner can open, and fails for files only the requester
// can open, when the two differ in elevation. Passing a handle opened as the requester (DiskBackend.virtual_disk) will
// close this gap.
L"echo ok",
FormatErrorMessage(
wsl::shared::Localization::MessageOpenVmmNestedVirtualizationConflict(),
L"Wsl/Service/CreateInstance/CreateVm/OpenVmm/ERROR_NOT_SUPPORTED"));

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants