Commit Graph

49 Commits

Author SHA1 Message Date
Blue
7778055874 Skip the LoadImage() test on server SKU's (#40350)
* Skip the LoadImage() test on server SKU's

* Update test/windows/WSLCTests.cpp

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

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-29 12:07:12 -07:00
Ben Hillis
bb56feb78e Set WSLC VM owner to WSLC-<DisplayName> for debuggability (#40346)
Use the session display name in the HCS VM owner field so that
hcsdiag list output shows which session owns each VM. This aids
debugging and allows tests to reliably identify their VM.

Falls back to 'WSLC' if DisplayName is null.

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-28 12:55:59 -07:00
Blue
19a757fe5e Fixed leaked container in NamedVolumesVhdSessionRecovery causing test failures in OpenContainer (#40316)
* Fixed leaked container in NamedVolumesVhdSessionRecovery causing test failures in OpenContainer

* Update comment
2026-04-25 13:46:04 -07:00
beena352
c8521c4be4 Add gateway driverOpt support in CreateNetwork and invalid input tests (#40278) 2026-04-23 20:21:38 -07:00
Blue
e096a5af0f Reuse virtiofs shares when possible (#40298)
* Reuse virtiofs shares when possible

* Use weakly_canonical and only delete in plan9 mode
2026-04-24 02:13:46 +00:00
Blue
3f47048189 Add support for anonymous port binds and --publish-all (#40288)
* Implement WSLCContainerFlagsPublishAll flag with CLI and tests

When the PublishAll flag is set, WSLCContainerImpl::Create() inspects the
container image to discover its ExposedPorts, creates TCP port mappings for
each exposed port that doesn't already have an explicit mapping, and uses
the resolved image ID for the container creation request to ensure the
same image is used.

CLI changes:
- Add --publish-all / -P flag to 'container create' and 'container run'
- Wire through ContainerOptions -> WSLCContainerFlagsPublishAll
- Add localization string for the new argument

Tests:
- PublishAllExposedPorts: builds an image with EXPOSE 8080 and 9090,
  verifies both ports get auto-mapped and the HTTP server is reachable
- PublishAllImageNotFound: verifies IMAGE_NOT_FOUND is returned when
  the flag is set with a nonexistent image

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

* Save state

* Prepare for PR

* Clean diff

* Cleanup diff

* Cleanup diff

* Apply PR feedback

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-23 18:38:57 -07:00
Kevin Vega
b70ae14303 Add "guest" volume driver (#40255) 2026-04-22 21:56:25 +00:00
beena352
e53fef3258 wslc: add network inspect (#40250) 2026-04-22 10:32:31 -07:00
Kevin Vega
e88a69697e Add DeleteVolumes flag to container deletion API (#40232) 2026-04-21 08:57:13 -07:00
Blue
2f4d1ec88f Use WSLC_E_CONTAINER_NOT_FOUND when a container is not found (#40251)
* Use WSLC_E_CONTAINER_NOT_FOUND when a container is not found

* Format
2026-04-20 14:58:25 -07:00
Ben Hillis
900f37ee34 Fix bugs found during code review of feature/wsl-for-apps (#40248)
- Fix wrong variable in waitpid check (init.cpp): Used 'Result' (poll return
  value) instead of 'Pid' (waitpid return value), causing incorrect SIGCHLD
  handling that could miss child exits or fail to detect init termination.

- Fix missing semicolon after LOG_ERROR (WSLCInit.cpp): Missing statement
  terminator would cause compilation failure on Linux builds.

- Fix misleading test comment (WSLCTests.cpp): Comment referenced port 1234
  but the test actually validates port 1236 cleanup after bind failure.

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-20 13:28:20 -07:00
beena352
11020d97ef wslc: add network create, delete, and list (#40179) 2026-04-19 16:52:53 -07:00
John Stephens
527e981791 Add --pull and --target flags to image build (#40216) 2026-04-17 13:30:48 -07:00
yao-msft
29b512f45e Add test coverage for LoadImage/ImportImage on process exit/session terminate (#40172)
* Add test covergae for LoadImage/ImportImage on process exit/session terminate

* fix handle read interupt

* do not leak container
2026-04-17 11:10:53 -07:00
Kevin Vega
e7acc41e7d Add wslc login, wslc logout, and wslc push commands for registry authentication (#40173) 2026-04-16 17:25:55 -07:00
Blue
3168f4c7a9 Add logic to keep track of COM callbacks and cancel them if the sessi… (#40183)
* Add logic to keep track of COM callbacks and cancel them if the session is terminating

* Apply PR feedback

* Format

* Reset the test session

* Apply PR feedback

* Apply PR suggestions
2026-04-15 17:31:33 -07:00
John Stephens
cef8c387ec Always show container logs during image builds (#40186) 2026-04-15 17:29:53 -07:00
Kevin Vega
fb132be887 Update volume APIs to match docker arguments (#40181) 2026-04-15 15:19:32 -07:00
Blue
f60ec519d5 Add support for --no-cache in BuildImage() & wslc.exe (#40174)
* Add support for --no-cache in BuildImage() & wslc

* Update test/windows/WSLCTests.cpp

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

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-14 13:26:26 -07:00
Ben Hillis
cd05f5c76d wslc: prevent session name squatting for default WSLc sessions (#40144)
* Prevent session name squatting for default WSLc sessions

- Server now determines default session name and settings from caller's
  token, preventing malicious users from squatting reserved session names
- CreateSession rejects explicit use of reserved names (wslc-cli,
  wslc-cli-admin) with case-insensitive E_ACCESSDENIED check
- Null StoragePath remains valid for ephemeral sessions; empty string
  is rejected as E_INVALIDARG
- Add dedicated EnterSession API with null/empty parameter validation
- Early return optimization: skip YAML parse if default session exists
- Inline BuildFeatureFlags into SessionSettings constructor
- Extract UserSettings into shared wslcsettings library used by both
  wslc.exe and wslservice.exe
- Move EnumVariantMap.h to common
- Fix std::terminate crash in CustomDmesgOutput test when CreateSession
  fails by adding a scope_exit guard to join the reader thread
- Add session name squatting E2E test with case-insensitive coverage

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

* Address PR feedback: per-user session names, custom error codes, impersonation

- Append username to default session names so different users don't
  collide (e.g. wslc-cli-alice, wslc-cli-admin-bob) [OneBlue]
- Impersonate caller when loading settings.yaml server-side [OneBlue]
- Factor name resolution into ResolveDefaultSessionName helper [OneBlue]
- Add WSLC_E_SESSION_RESERVED and WSLC_E_INVALID_SESSION_NAME error
  codes for better diagnosability [dkbennett]
- Use prefix-based reserved name check (blocks all wslc-cli-* names)
- Fix pre-existing HostFileShareMode namespace qualification bug
- Remove unused variable in GetDefaultStoragePath test helper [Copilot]
- Update all E2E tests for username-qualified session names

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-13 23:08:44 +00:00
Kevin Vega
723ffebfc6 Add registry authentication in runtime (#40123) 2026-04-13 15:47:46 -07:00
Blue
d84db74f09 Improve errors returned from WSLCContainer (#40147)
* Improve container state errors

* Add wslc.exe test coverage

* Fix localization file

* Apply PR suggestions

* Format
2026-04-10 14:56:54 -07:00
yao-msft
191fa5f906 Initial prune image support in wslc service (#40132) 2026-04-10 14:48:56 -07:00
Blue
e950342547 Add support for mounting files and non-existing folders as volumes (#40137)
* Save state

* Prepare for PR

* Apply PR feedback

* Add test coverage for restored containers

* Merge
2026-04-09 16:00:52 -07:00
Ben Hillis
9c4dba919f Refactor tests: use TAEF metadata for WSL version filtering (#40129)
Replace runtime WSL2_TEST_ONLY()/WSL1_TEST_ONLY() skip macros with
TAEF metadata-based test selection. Tests that don't apply to the
current WSL version are now excluded by /select: queries at selection
time rather than skipped at runtime, eliminating hundreds of 'skipped'
results from test output.

Changes:
- Add WSL2_TEST_METHOD, WSL1_TEST_METHOD, WSLC_TEST_METHOD macros
  in Common.h that tag tests with WSLVersion metadata property
- Convert ~430 test methods across 26 files to use new macros
- Update run-tests.ps1 to auto-add /select: version filter
- Update CloudTest XML configs with version selection queries
- Remove WSL2_TEST_ONLY() from composite macros in NetworkTests.cpp
- Update test README with new macro documentation

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-08 17:45:18 -07:00
Ben Hillis
c223800f46 wslc: implement dns tunneling for virtio proxy networking mode (#40104)
* wslc: implement dns tunneling for virtio proxy networking mode

This change implements dnstunneling for the virtio proxy networking mode. For now, this implementation uses the same socket-based approach, but in the fututure this will be moved over to the built-in dns support that is part of the wsldevicehost dll.

* wslc: enable DNS tunneling by default for virtio proxy

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

* Remove unused DNS test helpers

VerifyDnsResolutionDig and VerifyDnsResolutionRecordTypes are dead
code — VerifyDnsQueries is the superset that covers all record types
and TCP/UDP modes.

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 01:40:04 +00:00
Blue
3f7cb6bc7a Add logic to reject invalid flags (#40100)
* Add logic to reject invalid flags

* Simplify tests

* Use macros

* Format

* Format
2026-04-06 18:36:17 -07:00
Blue
c4d7711d19 Correctly handle empty arguments & entrypoint when launching containers (#40122)
* Correctly handle empty arguments & entrypoint when launching containers

* Apply PR feedback
2026-04-06 17:44:48 -07:00
Blue
9d39805c4d Implement wslc session enter (#40088)
* Save state

* Save state

* Save state

* Cleanup

* Prepare for PR

* Cleanup

* Validate flags

* Apply PR suggestions

* Add comment

* Remove include

* Cleanup diff

* Format

* Format

* Restore session flags
2026-04-06 11:51:09 -07:00
Blue
e146f6b027 Add logic to clean up images created during the tests (#40078)
* Save state

* Format

* Log failures

* Format
2026-04-03 18:40:37 -07:00
beena352
3cf4cfae27 Allow small timestamp difference in ContainerRecoveryFromStorage test (#40081)
* Allow small timestamp difference in ContainerRecoveryFromStorage test

* feedback
2026-04-02 20:50:08 -07:00
Blue
da5efafd45 Don't fail to start a WSLCSession if anonymous volumes are present (#40077)
* Don't fail to start a WSLCSession if anonymous volumes are present

* Typo

* Cleanup diff

* Cleanup diff
2026-04-02 12:24:48 -07:00
Blue
0c9f76c3a8 Fix race condition in ElevatedTokenCanOpenNonElevatedHandles test case (#40071) 2026-04-01 18:15:07 -07:00
beena352
dee42d80cb Add port mappings to container list output (#14438) 2026-04-01 16:34:13 -07:00
Blue
1cab9b06b8 Switch DmesgOutput to a WSLCHandle (#40063) 2026-04-01 13:51:09 -07:00
Kevin Vega
148545eae7 List and inspect named volumes (#14555) 2026-04-01 12:10:20 -07:00
Blue
c98558e9cc Use COM marshalling to exchange handles (#40056)
* Prototype

* Save state

* Save state

* Save state

* Save state

* Save state

* Save state

* Remove zeroing

* Apply PR feedback

* Add test coverage

* Format

* Add test coverage for null handles
2026-04-01 09:28:28 +00:00
John Stephens
713fcda944 Add support for build logs (#40054) 2026-03-31 20:38:29 -07:00
Blue
40e57130df Fix race condition in ContainerLogs test case (#40052) 2026-03-31 17:57:51 -07:00
Blue
37a5a99d9d Implement WSLAContainer::Kill() (#14560)
* Implement WSLAContainer::Kill()

* Add test coverage

* Format

* Apply PR feedback
2026-03-31 12:06:55 -07:00
Blue
832b0f7b50 Update wslc build to look for Containerfile and Dockerfile (#40045)
* Save state

* Add test coverage

* Rename method

* Require input handle in the service

* Apply PR feedback

* Format

* Apply PR feedback + update tests

* Format
2026-03-31 11:40:11 -07:00
John Stephens
dc7ec8f442 Add cancellation to image build (#14453) 2026-03-30 18:27:24 -07:00
Ben Hillis
68055596ee Reject port mappings exceeding 63-port limit in relay (#40035)
WaitForMultipleObjects has a 64-handle limit. The accept thread uses
1 handle for the exit event, leaving room for 63 port mappings.

Reject new port mappings with ERROR_TOO_MANY_OPEN_FILES when the limit
is reached, rather than crashing the relay thread. Existing mappings
continue to work.

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-30 13:00:35 -07:00
Kevin Vega
cc5f358e05 Allow retrieving state and init process info after container auto remove (#14429)
Allow clients to continue reading stdout/stderr and querying state from containers after they've been deleted, by caching the read-only data in the com wrapper.
2026-03-29 22:21:02 +00:00
Blue
933aedc79e Correctly set FileOffsets in WriteHandle (#14562)
* Correctly set FileOffsets in WriteHandle

* Apply PR suggestions
2026-03-28 11:44:02 -07:00
Blue
e7c520efd8 Use pre-imported container images in the tests to avoid hitting the API limit (#14561)
* Use pre-imported container images in the tests to avoid hitting the API limit

* Fix test case

* Update test/windows/wslc/e2e/WSLCE2EImageBuildTests.cpp

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

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-27 18:51:44 -07:00
Blue
7483642048 Various improvements to PullImage() + custom registry support (#14549)
* Save state

* Save state

* Handle issues during pull

* Disable the pull tests

* Update the CLI tests

* Format

* Fix legacy index logic

* Add test coverage for failed PullImage()

* Update test/windows/WSLCTests.cpp

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

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-27 18:50:56 -07:00
Blue
d5071295c1 Various improvements to interactions with user-provided handles (#14486)
* Save state

* Add test coverage

* Check the event under the lock

* Apply PR feedback

* Format

* Apply PR feedback
2026-03-27 16:13:29 -07:00
Ben Hillis
8973aeb8b5 cleanup: rename wsla -> wslc (#14502)
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-27 11:39:25 -07:00