17 Commits
Author SHA1 Message Date
Flor Elisa Chacon Ochoa a6e393a933 Merge remote-tracking branch 'origin/master' into fuzzing
# Conflicts:
#	CMakeLists.txt
#	src/windows/common/CMakeLists.txt
#	src/windows/wslc/CMakeLists.txt
2026-09-17 16:24:30 -07:00
9540481e9d Use unified kernel artifacts VHD layout (#41267)
Update the packaged kernel dependency from modules.vhd to artifacts.vhd and load kernel modules from the versioned <release>/modules directory. Preserve support for legacy flat module VHDs in the standard WSL boot path and teach WSLC sessions to mount modules from the nested layout.

Update development paths and kernel module tests for the renamed VHD and new mount source.

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

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Copilot-Session: a7cc3086-6311-4bc8-a591-49fd0e6b03fd
2026-08-20 10:57:27 -07:00
JohnMcPMS 5f213d1390 Merge branch 'master' into fuzzing 2026-08-17 14:16:17 -07:00
ggarzia-MSFTandCopilot 91fe87dae7 Enable Unity build for wslclib and enable CI unity builds (#41302)
Rename WSL_TEST_UNITY_BATCH_SIZE to WSL_UNITY_BATCH_SIZE and apply it to
wslclib as well as wsltests, so both targets share one knob. The default
is 0 (every file compiled separately) and the CI pipeline sets 4. Fixes
the name collisions that surface when sources are merged into a single
translation unit by fully qualifying details::WrapText,
details::ArgConvertedTypeMapping, and ::IUnknown, hoisting the duplicated
c_fallbackConsoleWidth constant into Terminal.h, and dropping redundant
includes. Adds benchmarking scripts under tools/benchmarking.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-12 12:02:09 -07:00
ggarzia-MSFTandCopilot 4ebaffce6f Enable unity builds for wsltests (#41247)
wsltests is a single large target whose compile time dominates local test
iteration. Enabling CMake unity builds batches test sources into shared
translation units, cutting wall-clock build time significantly.

Batch size is controlled by the new WSL_TEST_UNITY_BATCH_SIZE cache variable
(default 2). Setting it to 0 disables unity builds and compiles every file
separately, which is useful for isolating a build break to a single source
file. The value is validated at configure time and documented in
UserConfig.cmake.sample.

Concatenating sources into one translation unit surfaced latent collisions
that file scope had previously hidden:

- g_pipelineBuildId was defined as a separate file-static in both Common.cpp
  and InstallerTests.cpp. Common.cpp now owns the definition and
  InstallerTests.cpp declares it extern.
- ProcessOutput was declared at namespace scope in both WslcSdkTests.cpp and
  WslcSdkWinRTTests.cpp. The latter is renamed to CapturedProcessOutput.
- Broad `using namespace wsl::windows::common;` directives in
  WindowsUpdateTests.cpp, WSLCE2EHelpers.cpp, WSLCE2ETlsRegistryTests.cpp and
  WSLCExecutor.cpp leaked into neighboring sources and created ambiguous
  lookups. They are replaced with targeted using-declarations and namespace
  aliases.

Unity builds also change test execution order, which broke assertions that
implicitly depended on running before anything else had created a session.
WSLCTests::ListSessions and WSLCTests::SessionManagement now share a
ListTestSessionNames() helper that filters out the persistent sessions the
wslc CLI creates for itself, so the assertions no longer depend on what else
has run on the machine.

SessionManagement is the only test that creates persistent sessions, which
outlive the COM reference that created them. It now records the ones it
creates and terminates them from a scope_exit handler, so a failure partway
through cannot leak a session into subsequent runs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-06 17:53:15 -07:00
Blue b130d5bfed Add a UserConfig setting to use local wsldevicehost binaries instead of nuget (#41241) 2026-08-04 16:04:36 -07:00
Flor Elisa Chacon Ochoa c3522b9bbd Remove comment 2026-06-30 16:51:06 -07:00
Flor Elisa Chacon Ochoa ad2b83903c Add fuzzing for WSLC
Introduce libFuzzer/ASAN-based fuzzing for WSLC, run continuously via
OneFuzz in the nightly pipeline. Adds three harnesses covering the CLI
argument parser, the C SDK API, and the WinRT API.

Harnesses (src/windows/fuzzing/):
- WslcCliArgumentFuzzing: exercises ParseArgumentsStateMachine
- WslcSdkFuzzing: exercises the C SDK session/container flow
- WslcWinRtFuzzing: same, but using the WinRT projection
- FuzzingHarness.h: shared FuzzInput reader plus a replay main (gated on
WSL_ENABLE_FUZZING_REPLAY) for reproducing crashes locally
- generate-seeds.ps1: deterministic seed corpus generator, used for local
replay; SDK and WinRT share the same binary format
- OneFuzzConfig.json.in, setup.ps1: OneFuzz config and VM setup

Build (WSL_BUILD_FUZZING):
- Compiles the tree with /fsanitize=address so the service and SDK data
paths are instrumented; harness targets add /fsanitize=fuzzer
- Drops /guard:cf, /Qspectre, /CETCOMPAT (incompatible with ASAN)
- wslinstall is an MSI custom action that can't easily load the ASAN
runtime at install time. It isn't fuzzed, so build it without ASAN.
- Resolves clang_rt.asan_dynamic next to the compiler and ships it into
INSTALLDIR so instrumented binaries can load the runtime; the path is
also exported as a pipeline variable to stage next to the harnesses.

Pipeline (.pipelines/fuzzing-stage.yml): builds the harnesses and MSI,
stages the shared runtime, and submits each target to OneFuzz. Seeding is
left unwired for now (libFuzzer starts from an empty corpus); a
SeedCorpusContainer can be added later.

 Local dev notes added to README.md and UserConfig.cmake.sample.

 Fully vibe-coded with Copilot 🤖
2026-06-22 11:24:22 -07:00
Blue 4f211bd8ac Fix missing dxcore library in UserConfig.cmake.sample (#40841) 2026-06-18 11:45:36 -07:00
Flor Chacón 846bd564aa Add C# files to nuspec used in package stage (#40647) 2026-05-26 23:23:24 +00:00
Flor Chacón 07c7dbd9b5 Make it easier to make a local WSLC SDK NuGet (#40623) 2026-05-22 11:08:40 -07:00
+8 358ab87d40 Add WSLC (WSL Containers) feature (#40366)
WSLC is a container runtime built on the Windows Subsystem for Linux, enabling Windows applications to create and manage Linux containers through a native Windows API surface.

Key components:
- wslc.exe: CLI for managing containers, images, volumes, and networks
  (build, run, stop, inspect, push/pull from registries)
- wslcsession.exe: Per-user Windows service hosting container lifecycle,
  storage management, and networking
- WSLC SDK: C++ and C# client libraries with NuGet packaging for
  programmatic container management
- Container networking: port forwarding, DNS tunneling, virtio
  networking, and HCN integration
- Storage: VHD-backed volumes, virtiofs file sharing, overlayfs layers
- GPU passthrough and device host proxy support

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Co-authored-by: 1wizkid <richard.fricks@hotmail.com>
Co-authored-by: AmirMS <104940545+AmelBawa-msft@users.noreply.github.com>
Co-authored-by: beena352 <beenachauhan@microsoft.com>
Co-authored-by: Blue <OneBlue@users.noreply.github.com>
Co-authored-by: Craig Loewen <crloewen@microsoft.com>
Co-authored-by: Darshak Bhatti <47045043+dabhattimsft@users.noreply.github.com>
Co-authored-by: David Bennett <dbenne@microsoft.com>
Co-authored-by: Feng Wang <wang6922@outlook.com>
Co-authored-by: Flor Chacon <14323496+florelis@users.noreply.github.com>
Co-authored-by: John Stephens <johnstep@microsoft.com>
Co-authored-by: JohnMcPMS <johnmcp@microsoft.com>
Co-authored-by: Kevin Vega <40717198+kvega005@users.noreply.github.com>
Co-authored-by: Pooja Trivedi <poojatrivedi@gmail.com>
Co-authored-by: ramesh-ramn <raman.ramesh@gmail.com>
Co-authored-by: Richard Fricks <richfr@microsoft.com>
Co-authored-by: yao-msft <50888816+yao-msft@users.noreply.github.com>
2026-04-30 13:34:43 -07:00
b7735bba18 Replace pre-commit hook with CMake-generated clang-format check (#40136)
* Replace pre-commit hook with CMake-generated clang-format check

Replace the old pre-commit hook that shelled out to PowerShell and
never blocked commits (-NoFail) with a CMake-generated hook that
calls clang-format directly on staged C/C++ files.

- Add tools/hooks/pre-commit.in as a CMake template
- CMake resolves the clang-format path at configure time via
  LLVM_INSTALL_DIR, matching the existing FormatSource.ps1.in pattern
- Hook blocks commits on formatting errors, skips gracefully if
  clang-format is not available (cmake not yet run)
- ~5x faster than the old PowerShell approach (~0.5s vs ~2.6s)

* Make pre-commit hook behavior configurable via WSL_PRE_COMMIT_MODE

Add WSL_PRE_COMMIT_MODE CMake cache variable with three modes:
- warn (default): report formatting issues without blocking commit
- error: block commit when formatting issues are found
- fix: auto-format files and re-stage them

Also addresses PR feedback:
- Generate hook into build tree, copy to source tree for out-of-source builds
- Use repo-local tools/clang-format.exe instead of LLVM_INSTALL_DIR path
- Use @ONLY in configure_file to avoid shell variable substitution issues
- Document modes in dev-loop.md and UserConfig.cmake.sample

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-09 13:31:21 -07:00
Ben HillisandBen Hillis 4b23185dfe cleanup: fix UserConfig.cmake.sample in master branch (#14076)
* cleanup: fix UserConfig.cmake.sample in master branch

* remove incorrect wsldevicehost.dll handling, wix file always uses the version from the bin folder

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-01-16 15:30:05 -08:00
Ben HillisandBen Hillis c6ac7433b1 Fix minor typo in UserConfig.cmake.sample (.exe instead of .dll) (#13926)
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2025-12-16 11:37:03 -08:00
Blue 64160a40f0 Make the sample WSL_POST_BUILD_COMMAND more resilient (#13652) 2025-10-30 10:25:03 -07:00
WSL Team 697572d664 Initial open source commit for WSL.
Many Microsoft employees have contributed to the Windows Subsystem for Linux, this commit is the result of their work since 2016.

The entire history of the Windows Subsystem for Linux can't be shared here, but here's an overview of WSL's history after it moved to it own repository in 2021:

Number of commits on the main branch: 2930
Number of contributors: 31

Head over https://github.com/microsoft/WSL/releases for a more detailed history of the features added to WSL since 2021.
2025-05-15 12:09:45 -07:00