Skip to content

Richfr/ Add windowsAddress support to WslcCreateContainer() API#40037

Merged
1wizkid merged 33 commits intofeature/wsl-for-appsfrom
richfr/portmapping
Apr 14, 2026
Merged

Richfr/ Add windowsAddress support to WslcCreateContainer() API#40037
1wizkid merged 33 commits intofeature/wsl-for-appsfrom
richfr/portmapping

Conversation

@1wizkid
Copy link
Copy Markdown

@1wizkid 1wizkid commented Mar 30, 2026

Summary of the Pull Request

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Copilot AI review requested due to automatic review settings March 30, 2026 16:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the WSLC Client SDK’s container port-mapping path to support custom host binding addresses (including IPv6) instead of always binding to 127.0.0.1, and relaxes/updates validation around the windowsAddress field.

Changes:

  • Convert windowsAddress (IPv4/IPv6) into a string binding address for WSLCPortMapping during container creation.
  • Add input validation for windowsAddress->ss_family in WslcSetContainerSettingsPortMappings.

Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
Comment thread src/windows/WslcSDK/wslcsdk.cpp
Comment thread src/windows/WslcSDK/wslcsdk.cpp
Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
Copilot AI review requested due to automatic review settings April 1, 2026 17:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Comment thread src/windows/WslcSDK/wslcsdk.cpp
Comment thread src/windows/WslcSDK/wslcsdk.cpp
Comment thread src/windows/WslcSDK/wslcsdk.cpp
Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
Copilot AI review requested due to automatic review settings April 1, 2026 17:58
@1wizkid 1wizkid marked this pull request as ready for review April 1, 2026 18:00
@1wizkid 1wizkid requested a review from a team as a code owner April 1, 2026 18:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 6 comments.

Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
@1wizkid 1wizkid enabled auto-merge (squash) April 1, 2026 18:27
Copy link
Copy Markdown
Member

@JohnMcPMS JohnMcPMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost certainly needs a test update to prevent a negative test from failing when it passes in an address. Not sure if we can expect IPv6 everywhere, but at least passing in 127.0.0.1 (or maybe IPv6 loopback works even if no external IPv6 address is available?).

[Edit: Search suggests that IPv6 loopback is always available if device supports IPv6.]

Copy link
Copy Markdown
Collaborator

@OneBlue OneBlue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple comments, I would also recommend:

  • Updating the pull request title
  • Adding test coverage for the binding address wiring (at least for localhost, since that's the only thing that the service supports today)

You'll probably have to update existing tests as well

Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
@benhillis
Copy link
Copy Markdown
Member

Hey @1wizkid 👋 — Following up on this PR. Currently the wslc tests are failing in CI, and there are 11 unresolved review threads with feedback from maintainers, including:

  • Missing test coverage
  • Dangling pointer concerns (flagged 4 times)
  • Wildcard port binding security concern
  • \E_UNEXPECTED\ error code usage
  • \AF_UNSPEC\ failure risk

Is this change still needed? The review feedback covers some important safety and design issues that should be addressed before this can move forward. Let us know if you need any help!

@1wizkid
Copy link
Copy Markdown
Author

1wizkid commented Apr 7, 2026 via email

Copilot AI review requested due to automatic review settings April 7, 2026 16:54
@1wizkid 1wizkid closed this Apr 7, 2026
auto-merge was automatically disabled April 7, 2026 16:54

Pull request was closed

@1wizkid 1wizkid force-pushed the richfr/portmapping branch from 7f1eca4 to 715ce52 Compare April 7, 2026 16:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 4 changed files in this pull request and generated 4 comments.

Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
Comment thread src/windows/WslcSDK/wslcsdk.cpp
Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
Comment thread test/windows/WslcSdkTests.cpp Outdated
Comment thread test/windows/WslcSdkTests.cpp
Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
Copilot AI review requested due to automatic review settings April 13, 2026 21:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 4 changed files in this pull request and generated 3 comments.

Comment thread src/windows/WslcSDK/wslcsdk.cpp
Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
Copilot AI review requested due to automatic review settings April 13, 2026 22:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Comment thread diagnostics/trace01.etl Outdated
Copy link
Copy Markdown
Collaborator

@OneBlue OneBlue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the .etl file before merging

@1wizkid 1wizkid enabled auto-merge (squash) April 14, 2026 14:06
Copilot AI review requested due to automatic review settings April 14, 2026 16:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

{
if (inet_ntop(af, src, dst, dstCount) == nullptr)
{
return HRESULT_FROM_WIN32(WSAGetLastError());
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If inet_ntop() returns null but WSAGetLastError() happens to be 0 (e.g., stale last-error state), HRESULT_FROM_WIN32(0) will incorrectly return S_OK. Consider capturing the error immediately and returning a non-success fallback when the error code is 0 (e.g., E_FAIL), or proactively setting/clearing last error before calling inet_ntop().

Suggested change
return HRESULT_FROM_WIN32(WSAGetLastError());
const auto lastError = WSAGetLastError();
return lastError == 0 ? E_FAIL : HRESULT_FROM_WIN32(lastError);

Copilot uses AI. Check for mistakes.
Comment on lines +778 to +780
WslcContainerSettings containerSettings1;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings1));
VERIFY_SUCCEEDED(WslcSetContainerSettingsNetworkingMode(&containerSettings1, WSLC_CONTAINER_NETWORKING_MODE_NONE));
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new containerSettings1containerSettings5 names don’t communicate intent and make the test harder to scan. Consider using descriptive names tied to the scenario (e.g., noneNetworkingSettings, defaultBindSettings, ipv4BindSettings, ipv6BindSettings, badFamilySettings) to improve readability and reduce the chance of mixing settings between blocks.

Copilot uses AI. Check for mistakes.
Comment on lines +803 to +806
WslcContainerSettings containerSettings2;
VERIFY_SUCCEEDED(WslcInitContainerSettings("python:3.12-alpine", &containerSettings2));
VERIFY_SUCCEEDED(WslcSetContainerSettingsInitProcess(&containerSettings2, &procSettings));
VERIFY_SUCCEEDED(WslcSetContainerSettingsNetworkingMode(&containerSettings2, WSLC_CONTAINER_NETWORKING_MODE_BRIDGED));
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new containerSettings1containerSettings5 names don’t communicate intent and make the test harder to scan. Consider using descriptive names tied to the scenario (e.g., noneNetworkingSettings, defaultBindSettings, ipv4BindSettings, ipv6BindSettings, badFamilySettings) to improve readability and reduce the chance of mixing settings between blocks.

Copilot uses AI. Check for mistakes.
Comment on lines +838 to +841
WslcContainerSettings containerSettings3;
VERIFY_SUCCEEDED(WslcInitContainerSettings("python:3.12-alpine", &containerSettings3));
VERIFY_SUCCEEDED(WslcSetContainerSettingsInitProcess(&containerSettings3, &procSettings));
VERIFY_SUCCEEDED(WslcSetContainerSettingsNetworkingMode(&containerSettings3, WSLC_CONTAINER_NETWORKING_MODE_BRIDGED));
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new containerSettings1containerSettings5 names don’t communicate intent and make the test harder to scan. Consider using descriptive names tied to the scenario (e.g., noneNetworkingSettings, defaultBindSettings, ipv4BindSettings, ipv6BindSettings, badFamilySettings) to improve readability and reduce the chance of mixing settings between blocks.

Copilot uses AI. Check for mistakes.
Comment on lines +879 to +882
WslcContainerSettings containerSettings4;
VERIFY_SUCCEEDED(WslcInitContainerSettings("python:3.12-alpine", &containerSettings4));
VERIFY_SUCCEEDED(WslcSetContainerSettingsInitProcess(&containerSettings4, &procSettings));
VERIFY_SUCCEEDED(WslcSetContainerSettingsNetworkingMode(&containerSettings4, WSLC_CONTAINER_NETWORKING_MODE_BRIDGED));
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new containerSettings1containerSettings5 names don’t communicate intent and make the test harder to scan. Consider using descriptive names tied to the scenario (e.g., noneNetworkingSettings, defaultBindSettings, ipv4BindSettings, ipv6BindSettings, badFamilySettings) to improve readability and reduce the chance of mixing settings between blocks.

Copilot uses AI. Check for mistakes.
Comment on lines +913 to +915
WslcContainerSettings containerSettings5;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings5));
VERIFY_SUCCEEDED(WslcSetContainerSettingsNetworkingMode(&containerSettings5, WSLC_CONTAINER_NETWORKING_MODE_BRIDGED));
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new containerSettings1containerSettings5 names don’t communicate intent and make the test harder to scan. Consider using descriptive names tied to the scenario (e.g., noneNetworkingSettings, defaultBindSettings, ipv4BindSettings, ipv6BindSettings, badFamilySettings) to improve readability and reduce the chance of mixing settings between blocks.

Copilot uses AI. Check for mistakes.
@1wizkid 1wizkid merged commit 630929d into feature/wsl-for-apps Apr 14, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants