* 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>
* 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>
- 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>
* 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>
* 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>
* virtiofs: update logic so querying virtiofs mount source does not require a call to the service
* more pr feedback
* use std::filesystem::read_symlink
* pr feedback and use canonical path in virtiofs symlink
* make sure canonical path is always used
---------
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
* 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>
Use ResolveIpNetEntry2 to look up the host gateway's MAC address and
pass it as the gateway_mac device option to the virtio net adapter.
This allows the guest to see the real gateway MAC instead of the
default consomme address.
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
* Refactor: Use TryParse in view models for safer numeric input parsing
Replaces parsing logic with TryParse across view models to prevent overflow/format crashes from invalid user input. Specifically fixes the VM Idle Timeout crash reported in #14312, while improving stability for other numeric settings.
* Fix crash when opening Optional Features settings page
Bug 1 - LxssHttpProxy.cpp: IPv6 substr extraction used wrong length
calculation. substr(openBracket+1, closeBracket-1) is incorrect when
openBracket > 0; fixed to substr(openBracket+1, closeBracket-openBracket-1).
Also fixed empty-address guard to check closeBracket (not closeBracket-1).
Bug 2 - LxssUserSession.cpp: Two instances of reinterpret_cast<HANDLE*> in
ScopedMultiRelay construction should be reinterpret_cast<HANDLE> (without
the pointer). Other identical callsites in the same file already use the
correct cast.
Bug 3 - LxssUserSession.cpp: GetLastError() was called unconditionally after
CreateFileW, even on success. A stale ERROR_SHARING_VIOLATION from a prior
API call could cause a false throw. Fixed to only check GetLastError() when
CreateFileW fails (!vhd).
Bug 4 - plan9.cpp: sun_path bounds check used > instead of >= leaving no room
for null terminator. Also added a post-split check to ensure the child name
fits after splitting parent/child for long paths.
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
* 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
* Initial plan
* Fix excessive screen updates during wsl --export
Only update progress display when file size actually changes, preventing
unnecessary screen redraws and reducing CPU/GPU overhead.
Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
* Address code review: initialize previousSize to 0 instead of -1
Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
* Complete fix for excessive screen updates during wsl --export
Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
* Clean up: remove codeql symlink and add to gitignore
Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
* Revert .gitignore to original state
Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
* Compare MB values instead of raw bytes to prevent unnecessary redraws
When file size grows in sub-MB increments, comparing raw bytes causes
redraws even though the displayed MB value hasn't changed. Now we
calculate and compare the MB value directly, ensuring the progress
indicator only updates when the displayed value actually changes.
Also initialize previousSizeMB to -1 to ensure initial progress is
always shown (even when starting at 0 MB).
Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
* Cache string in UpdateProgress instead of caching values in caller
Move the duplicate string check into ConsoleProgressIndicator::UpdateProgress()
itself. This provides a more general solution that prevents printing the same
string twice for any caller, not just the file size case. The comparison now
happens at the string level, which handles all formatting variations and makes
the fix more maintainable.
Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
* 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>
* 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>
* 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>
The ConsoleInput and ConsoleOutput classes used = default move operations, which caused the moved-from temporary's destructor to restore the original console mode (re-enabling ENABLE_PROCESSED_INPUT) after the object was moved into the std::optional. The fix uses emplace() to construct objects directly in-place, avoiding moves entirely. Move operations are now deleted to prevent future misuse.
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
* 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>
* Clean up localhost relay implementation to not rely on procfs parsing.
* pr feedback
---------
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
* 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>