71 Commits

Author SHA1 Message Date
Feng Wang
9c5b7e988a Fix random "ERROR_FILE_NOT_FOUND" when unmounting with absolute path (#40092)
Fix ERROR_FILE_NOT_FOUND when unmounting a vhd with absolute path after the vm timeouts.
2026-04-10 11:17:22 +08:00
Ben Hillis
1a2ede7501 Mask console-getty.service to prevent multi-distro failures (#13595) (#14490)
* Mask console-getty.service to prevent multi-distro failures (#13595)

When multiple WSL distros run concurrently, /dev/tty devices are shared
at the VM level. The second distro's console-getty.service fails because
the tty is already held by the first, causing systemd to report failed
units and triggering user@UID.service failures.

Mask console-getty.service during WSL systemd unit generation, similar
to the existing masking of networkd-wait-online. This service provides
no value in WSL since users don't connect to the underlying tty.

Fixes #13595

* format source

* pr feedback

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-04-09 13:32:11 -07:00
Ben Hillis
8496b4051c Add /attachdebugger option to automatically launch WinDbgX for test debugging (#40116)
* Add /attachdebugger option to automatically launch WinDbgX for test debugging

When /attachdebugger is passed to test.bat, run-tests.ps1 now:
- Starts te.exe with /waitfordebugger in the background
- Polls for the TE.ProcessHost.exe child process via WMI
- Launches WinDbgX attached directly to the test host PID
- With /inproc, attaches to TE.exe itself instead

This replaces the manual workflow of running /waitfordebugger, reading
the PID from the output, and launching WinDbgX separately.

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

* run-tests: use /inproc with /attachdebugger, simplify exit

Per review feedback from @OneBlue:
- Add /inproc when /attachdebugger is set so WinDbgX attaches
  directly to TE.exe instead of polling for TE.ProcessHost.exe
- Simplify exit to pass through TE.exe exit code directly

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

* docs: update /attachdebugger to reflect /inproc behavior

The script now always adds /inproc, so update the README to match:
WinDbgX attaches directly to TE.exe, no ProcessHost polling.

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

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-07 18:45:37 -07:00
Ben Hillis
f9f1c38d9f devicehost: stop re-signing and fix MSI installer failing to replace wsldevicehost.dll (#40075)
* devicehost: stop re-signing and fix MSI installer failing to replace
wsldevicehost.dll

* pr feedback

* use MSIRMSHUTDOWN = 1 instead of custom action

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-04-06 15:10:26 -07:00
Ben Hillis
cf3182594c Update Microsoft.WSL.DeviceHost to version 1.1.48-0 (#40036)
* Update Microsoft.WSL.DeviceHost to version 1.1.48-0 (#14575)

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

* Re-enable WSLG during testing.

This reverts commit bf759a092b.

* add back config change (will work with new default, but makes test explicit)

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-30 11:13:10 -07:00
Ben Hillis
bf759a092b Revert "test: enable virtiofs tests and enable WSLG during testing (#14387)" (#14538)
* Revert "test: enable virtiofs tests and enable WSLG during testing (#14387)"

* enable wslg for SystemdNoClearTmpUnit test

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-26 17:50:31 -07:00
Ben Hillis
7370bf2bb5 virito net: revert to previous DNS behavior while we debug an issue with DNS over TCP (#14532)
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-25 13:30:35 -07:00
Feng Wang
83d59d4b4a Fix: Fail and warn the user when --uninstall is given parameters (#14524)
Fail and warn the user when --uninstall is given parameters.
2026-03-25 13:08:56 +08:00
Ben Hillis
2b51002705 test: remove duplicated DNS test coverage (#14522)
* test: remove duplicated DNS test coverage

* format source

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-24 19:22:36 -07:00
Ben Hillis
dd88ff737c test: Add arm64 test distro support (#14500)
* test: Add arm64 test distro support

* update unit test baseline

* more test baseline updates

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-23 11:20:03 -07:00
Feng Wang
61e6b9aa86 Fix wsl stuck when misconfigured cifs mount presents (#14466)
* detach terminal before running mount -a

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* use _exit on error before execv in child process to avoid unintentional resource release

* Add regression test

* Fix clang format issue

* fix all clang format issue

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* resolve ai comments

* move test to unit test

* Fix string literal

* Overwrite fstab to resolve pipeline missing file issue

---------

Co-authored-by: Feng Wang <wangfen@microsoft.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-20 12:45:46 -07:00
Ben Hillis
d7ff5b9631 Refactor: trim unnecessary DLL deps from COMMON_LINK_LIBRARIES (#14426)
* Refactor: trim unnecessary DLL deps from COMMON_LINK_LIBRARIES

- Split MSI/Wintrust install functions from wslutil.cpp into install.cpp
- Remove MI.lib, wsldeps.lib, msi.lib, Wintrust.lib, computecore.lib,
  computenetwork.lib, Iphlpapi.lib from COMMON_LINK_LIBRARIES
- Add per-target MSI_LINK_LIBRARIES, HCS_LINK_LIBRARIES, SERVICE_LINK_LIBRARIES
- Delay-load msi.dll and WINTRUST.dll for wsl.exe and wslg.exe
- Result: wslhost, wslrelay, wslcsdk, testplugin lose msi/wintrust startup imports;
  wsl.exe and wslg.exe defer msi/wintrust loading until actually needed;
  wslservice is the only target that imports computecore/computenetwork/Iphlpapi

* minor fixes to install.cpp that were caught during PR

* move to wsl::windows::common::install namespace

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-19 12:45:58 -07:00
Ben Hillis
6425aa8acc test: disable LoopbackExplicit due to OS build 29555 regression (#14477)
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-19 05:45:56 +00:00
Ben Hillis
c5fb4aa639 Enable DNS tunneling for VirtioProxy networking mode (#14461)
- Allow VirtioProxy to keep EnableDnsTunneling=true in config, but clear
  socket-specific options (BestEffortDnsParsing, DnsTunnelingIpAddress)
- Suppress dedicated DNS tunneling hvsocket for VirtioProxy; tunneling
  is handled through the VirtioNetworking device host instead
- Set DnsTunneling flag on VirtioNetworkingFlags so the device host
  knows to tunnel DNS
- Expand SWIOTLB kernel cmdline to cover VirtioFs and VirtioProxy
- Bump DeviceHost package to 1.1.39-0
- Add VirtioProxy DNS test coverage for tunneling on/off
- Skip GuestPortIsReleasedV6 on Windows 10

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-18 15:31:04 -07:00
Daman Mulye
ef8e1c8dba Track bind syscall when port is 0 (#14333)
* Initial work

* .

* pr feedback and add unit test

* minor tweaks an fix use after free in logging statement

* implement PR feedback

* hopefully final pr feedback

* pr feedback in test function

* Address PR feedback: add try/catch to TrackPort and PortZeroBind queue push

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-13 17:00:57 -07:00
Ben Hillis
7cd9ed9603 virtio networking: add support for ipv6 (#14350)
* VirtioProxy: Add IPv6 address, gateway, and route support

- Add PreferredIpv6Address field and GetBestGatewayV6* methods to NetworkSettings
- Extend GetHostEndpointSettings() to discover IPv6 unicast address and gateway
- Add UpdateIpv6Address() using ModifyGuestEndpointSettingRequest<IPAddress>
- Push IPv6 default route to guest via UpdateDefaultRoute(AF_INET6)
- Remove AF_INET6 early return in ModifyOpenPorts, use INETADDR_PORT()
- Add EndpointRoute::DefaultRoute() static factory
- Pass client_ip_ipv6 in devicehost options (not yet parsed by devicehost)
- Remove gateway_ip from devicehost options (only needed for DHCP)
- Include IPv6 DNS servers in non-tunneling DNS settings
- Add ConfigurationV6 and DnsResolutionAAAA tests

* cleanup and add more ipv6 tests

* added test coverage and minor updates

* clang format

* pr feedback

* format source

* pr feedback

* test fixes

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-13 16:36:21 -07:00
Ben Hillis
e5cb458e67 Ship initrd.img in MSI using build-time generation via powershell script (#14424)
* Ship initrd.img in MSI using build-time generation via tar.exe

Replace the install-time CreateInitrd/RemoveInitrd custom actions with a
build-time step that generates initrd.img using the Windows built-in
tar.exe (libarchive/bsdtar) and ships it directly in the MSI.

The install-time approach had a race condition: wsl.exe could launch
before the CreateInitrd custom action completed, causing
ERROR_FILE_NOT_FOUND for initrd.img.

Changes:
- Add CMake custom command to generate initrd.img via tar.exe --format=newc
- Add initrd.img as a regular file in the MSI tools component
- Remove CreateInitrd/RemoveInitrd custom actions from WiX, DllMain,
  and wslinstall.def
- Remove CreateCpioInitrd helper and its tests (no longer needed)
- Update pipeline build targets to build initramfs instead of init

* pr feedback

* more pr feedback

* switch to using a powershell script instead of tar.exe

* powershell script feedback

* hopefully final pr feedback

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-12 20:42:24 -07:00
Ben Hillis
3167b72018 test: enable virtiofs tests and enable WSLG during testing (#14387)
* test: enable virtiofs tests and enable WSLG during testing

* test fix

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-10 12:34:56 -07:00
Ben Hillis
8c220dc083 Fix grammar, typos, and formatting in docs and source (#14286)
* Fix localization text, Intune capitalization, ADMX indentation, unused import

- distributions/validate.py: Remove unused 'import base64'
- en-US/en-GB Resources.resw: Fix word order 'the list distribution' -> 'the distribution list' in MessageCouldFetchDistributionList
- en-US/en-GB Resources.resw: Remove trailing space from MessageCorruptedDistroRegistration value
- intune/en-US/WSL.adml: Fix 'For Linux' -> 'for Linux' capitalization (5 occurrences) to match official product name
- intune/WSL.admx: Fix inconsistent 3-space indent to 4-space on AllowWSL1 and CustomKernelUserSettingConfigurable policies

* Fix grammar, typos, and formatting in docs and source code

- WmiService.h: Fix duplicated word 'of of' -> 'is of' in WQL comment
- drvfs.md: Fix 'which tell' -> 'which tells' (subject-verb agreement), double space, second 'tell' -> 'tells'
- systemd.md: Fix 'tries synchronizes' -> 'tries to synchronize'
- wslhost.exe.md: Fix 'processes terminates' -> 'process terminates'
- boot-process.md: Add missing 'in' preposition, fix C:/ -> C:\, fix lowercase 'linux' to 'Linux' (4 occurrences), fix misplaced parenthesis
- init.md: Fix double space before hvsocket backtick
- session-leader.md: Fix heading level ## -> ### to match sibling section
- CONTRIBUTING.md: Fix double period after bold security notice
- debugging.md: Fix missing word 'be' in 'can enabled', fix 'process' -> 'processes'
- index.md: Add missing period at end of sentence
- technical-documentation/index.md: Fix 'API's' -> 'APIs' (remove incorrect apostrophe)
- relay.md: Fix lowercase 'linux' to 'Linux' (3 occurrences)
- localhost.md: Fix lowercase 'linux' to 'Linux'
- plan9.md: Fix lowercase 'linux' to 'Linux'

* update errormessages testcase

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-03 18:13:59 -08:00
Dimitris Chatzis
cb35b511cc Mask NetworkManager-wait-online.service during boot (#14272)
* Mask NetworkManager-wait-online.service during boot

Fixes #13772. Similar to PR #13611, this masks NetworkManager-wait-online.service to prevent 60-second timeouts during boot since WSL interfaces are unmanaged by NetworkManager. Also added the service to the discouraged units list in validate-modern.py and added a unit test.

* Addressed Copilot feedback

* Fix
2026-02-25 17:39:56 -08:00
Ben Hillis
66822ce4ce Update Microsoft.WSL.DeviceHost with virtiofs and virtio networking (#14198)
improvements.

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-02-12 13:05:45 -08:00
Ben Hillis
ae39345d90 Minor follow-up initrd feedback items (#14186)
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-02-09 13:39:29 -08:00
Ben Hillis
0e263df6f3 Move from shipping the initrd to generating it during install. (#14119)
* Move from shipping the initrd to generating during package install.

* pr feedback

* working

* adjust custom action conditions

* update initrd test to cover more cases

* Update msipackage/package.wix.in

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

* use stack buffer

* move initrd helper to filesystem.cpp and add unit test

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-07 12:47:56 -08:00
Ben Hillis
8aadbb4da5 DNS: Simplify dns logic and switch to using 'search' instead of 'domain' which is obsolete. (#14133)
* DNS: Simplify dns logic and switch to using 'search' instead of 'domain'
which is obsolete.

* add optional header for natnetworking

* format

* extend configuration test for virtioproxy networking mode

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-02-02 16:06:46 -08:00
Ben Hillis
4096e6d77d virtiofs: add support for mounting directories (not just full volumes) (#14073)
* virtiofs: add support for mounting directories (not just full volumes)

* disable virtiofs tests for now

* spelling

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-01-29 09:16:54 -08:00
Ben Hillis
081388c5f5 virtiofs: add support for statx syscall (#14087)
* virtiofs: add support for statx syscall

* add statx drvfs test

* skip statx drvfs test on wsl1

* skip stax tests on smb and fat

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-01-23 14:09:41 -08:00
Ben Hillis
5e09668fb7 TEST: Add testcases to validated bridged networking connectivity (#14042)
* TEST: Add testcases to validated bridged networking connectivity

* minor bridged test updates

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-01-09 13:56:01 -08:00
Ben Hillis
f459aef63d virtiofs: enable test case for mapping virtiofs MAP_PRIVATE (#13964)
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2025-12-23 09:26:20 -08:00
Ben Hillis
77a35b9a0c virtiofs: enable additional test cases and skip one racey test (#13933)
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2025-12-17 14:02:07 -08:00
Ben Hillis
c5fd672847 test: add more path translation variations (#13927)
* test: add more path translation variations

* Update test/windows/SimpleTests.cpp

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

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2025-12-16 18:53:04 -08:00
Ben Hillis
d0609393e4 [GH 13837] Remove trailing slash from $XDG_RUNTIME_DIR (#13929)
* [GH 13837] Remove trailing slash from $XDG_RUNTIME_DIR

* pr feedback

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2025-12-16 18:52:15 -08:00
Ben Hillis
f02f8ef91c cleanup: remove duplicate AppId registration for wsldevicehost.dll (#13928)
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2025-12-16 16:30:46 -08:00
Ben Hillis
d48d374c8c test: extend networking test coverage (#13914)
* test: extend coverage of virtioproxy networking mode

* test: add dns test variations to all networking classes

* remove bridged dns variations

* pr feedback

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2025-12-16 14:20:26 -08:00
Ben Hillis
180d811099 Resolve issue with config file writing sections outside of their expected header. (#13898)
* Resolve issue with config file writing sections outside of their expected header.

* add more writewslconfig variations

* formatting

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2025-12-15 13:03:02 -08:00
Ben Hillis
f1e20b21c9 Clean up localhost relay implementation to not rely on procfs parsing. (#13836)
* Clean up localhost relay implementation to not rely on procfs parsing.

* pr feedback

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2025-12-12 14:18:07 -08:00
Ben Hillis
19f06f9f51 virtiofs: fix an issue where if the VM is launched by an elevated user, non-elevated shells will have elevated virtiofs access. (#13877)
* virtiofs: fix an issue where if the VM is launched by an elevated user, non-elevated shells will have elevated virtiofs access.

* rename keelAlive -> keepAlive

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2025-12-11 15:21:27 -08:00
Ben Hillis
25572cc168 test: add simple virtio proxy networking tests and move mirrored tests to their own class (#13838)
* test: add simple virtio proxy networking tests

* move mirrored tests to their own class

* fix failing mirrored variation

* use different port for HostUdpBindDoesNotPreventGuestTcpBind

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2025-12-10 09:41:55 -08:00
Ben Hillis
2844e4a862 test: minor updates to improve virtiofs pass rate (#13815)
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2025-12-02 12:46:26 -08:00
Ben Hillis
0f6f3c1e02 test: improve test logging infra (#13811)
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2025-12-01 21:17:28 -08:00
Ben Hillis
66904342a5 cleanup: switch from Microsoft::WRL::ComPtr to wil::com_ptr (#13767)
* cleanup: switch from Microsoft::WRL::ComPtr to wil::com_ptr

* reformat

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2025-11-24 12:47:22 -08:00
Blue
f75997128d Mask systemd-networkd-wait-online.service during boot (#13611) 2025-11-20 09:23:12 -08:00
Ben Hillis
b73897e88a build: fix minor compiler errors when building with VS2026 (#13744)
* build: fix minor compiler errors when building with VS2026

* s

* use VS2022 for clang format and cross compiling

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2025-11-19 15:35:49 -08:00
Ben Hillis
9e9ef6f145 Fix edge cases around .vhd support (#13061)
* Fix edge cases around .vhd support

* PR feedback

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

* pr feedback

* remove unneeded scope exit in unit test

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-21 17:00:47 -07:00
Blue
9f77522f64 Update the initramfs to set 755 permissions on /init (#13567) 2025-10-06 17:19:49 -07:00
Blue
9b5659d4b9 Respect the distribution manifest ordering when listing distributions (#13561)
* Respect the distribution manifest ordering when listing distributions

* Fix test

* Update test/windows/UnitTests.cpp

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

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-06 12:42:32 -07:00
Blue
d4e64b658f Add more verbose output to bsdtar to help root cause 'ImportExportStdout' test failures (#13555) 2025-10-03 17:37:40 -07:00
Blue
65eea7b31c Introduce a new wsl.conf config value to allow distributions to opt-in to cgroupv1 mounts (#13546)
* Introduce a new wsl.conf config value to allow distributions to opt-in to cgroupv1 mounts

* Add test coverage

* Fix tmpfs on wsl1

---------

Co-authored-by: Ben Hillis <benhillis@gmail.com>
2025-10-02 23:36:12 -04:00
Junhao Liao
98f4960118 fix: correct sparse VHD command to include true (#13512)
* fix: correct sparse VHD command to include `true`

* Revert all localization strings to f8c26f7c3 except en-US/Resources.resw

* fix: run validate-localization.py with --fix option
2025-10-01 16:49:49 -07:00
Blue
8313d50f2e Introduce a new kernel command line argument to collect hvsocket event logs during boot (#13537)
* Introduce a new kernel command line argument to collect hvsocket event logs during boot

* Cleanup diff

* unset env

* Add test coverage

* Fix format

* Remove prefix
2025-10-01 15:35:49 -07:00
Blue
04eb4d4e8f Increase the MSI installation timeout to 20 minutes (#13489)
* Increase the MSI installation timeout to 20 minutes

* Increase the MSI installation timeout to 20 minutes
2025-09-17 11:27:12 -07:00