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>
* 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>
- 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>
* 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
* 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>
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>
* 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>
* 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
* 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
* Save state
* Add test coverage
* Rename method
* Require input handle in the service
* Apply PR feedback
* Format
* Apply PR feedback + update tests
* Format
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>
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.
* 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>