Skip to content

Fix VHD operations on older Windows versions - #42041

Merged
Ben Hillis (benhillis) merged 1 commit into
masterfrom
benhill/fix-vhd-open-version-check
Oct 23, 2026
Merged

Ben Hillis (benhillis) merged 1 commit into
masterfrom
benhill/fix-vhd-open-version-check

Conversation

@benhillis

Copy link
Copy Markdown
Member

Summary of the Pull Request

Fix the older-Windows regression introduced by #42008. Only pass OPEN_VIRTUAL_DISK_FLAG_SUPPORT_ENCRYPTED_FILES on build 22631 (Nickel_23H2) and later, and apply the same minimum version to CompactEncrypted.

cc Feng Wang (@chemwolf6922)

PR Checklist

  • Closes: No separate issue; fixes a regression from Fix encrypted disk support for compact #42008.
  • 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: Not applicable.

Detailed Description of the Pull Request / Additional comments

Windows 10 22H2 and Windows Server 2022 reject the encrypted-file support flag with ERROR_INVALID_PARAMETER, even when opening an unencrypted VHD. This breaks TestExistingSwapVhd, Resize, Compact, and CompactEncrypted.

The existing CI results show all four tests failing on those releases and passing on Windows 11 23H2 and Windows Server 2025. Build 22631 is the oldest confirmed passing version in that matrix; this does not establish the flag's exact introduction version on earlier, untested Windows 11 releases.

Older builds now use OPEN_VIRTUAL_DISK_FLAG_NONE. Supported builds retain encrypted-VHD support. The encrypted-compaction test skips before creating a distribution on older builds. No new user-facing strings or documentation changes are needed.

Validation Steps Performed

  • cmake --build . --clean-first -- -m - passed for the final changes.

  • .\FormatSource.ps1 -Verify $true - passed.

  • git -c core.whitespace=cr-at-eol diff --check - passed.

  • python3 tools\devops\validate-copyright-headers.py - failed during the full-tree scan with a UnicodeEncodeError while printing filenames. The existing validator's has_header check passed for both changed files using:

    python3 -c "import runpy; v = runpy.run_path(r'tools\devops\validate-copyright-headers.py'); paths = [r'src\windows\common\WslCoreFilesystem.cpp', r'test\windows\wsl\UnitTests.cpp']; missing = [p for p in paths if not v['has_header'](p)]; print('Changed-file copyright headers: ' + ('FAILED: ' + ', '.join(missing) if missing else 'PASS (2 files)')); raise SystemExit(bool(missing))"
  • Runtime tests were not run locally to avoid replacing the installed WSL package and stopping active sessions. CI should verify TestExistingSwapVhd, Resize, Compact, and the version-gated CompactEncrypted test across the Windows matrix.

Only request encrypted-file support on Windows build 22631 and later, and skip CompactEncrypted on older builds. Fixes the older-Windows regression introduced by #42008.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7aea2e49-4dd6-4657-bc07-495d2cfe7cae
Copilot AI balanced review requested due to automatic review settings October 23, 2026 16:05
@benhillis
Ben Hillis (benhillis) requested a review from a team as a code owner October 23, 2026 16:05

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

No blocking code defects were identified, but Windows-matrix runtime validation remains pending for the affected VHD operations.

No open issues 🎉

What changed in this PR

This PR addresses the older-Windows VHD regression introduced by #42008 while retaining encrypted-VHD support on build 22631 and later.

Changes:

  • Gate OPEN_VIRTUAL_DISK_FLAG_SUPPORT_ENCRYPTED_FILES on Nickel_23H2; older builds use OPEN_VIRTUAL_DISK_FLAG_NONE.
  • Apply the same minimum version to CompactEncrypted, skipping before distribution creation.
File Description
test/​windows/​wsl/​UnitTests.cpp Skip encrypted-compaction testing below build 22631.
src/​windows/​common/​WslCoreFilesystem.cpp Select VHD open flags based on the Windows build.

Review effort: Balanced

@benhillis
Ben Hillis (benhillis) merged commit 4cd95ae into master Oct 23, 2026
12 checks passed
@benhillis
Ben Hillis (benhillis) deleted the benhill/fix-vhd-open-version-check branch October 23, 2026 18:28
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.

4 participants