Skip to content

Add WSLCContainerNetworkTypeCustom support#40311

Open
beena352 wants to merge 5 commits intomicrosoft:feature/wsl-for-appsfrom
beena352:user/beenachauhan/wslc-container-user-defined-networks
Open

Add WSLCContainerNetworkTypeCustom support#40311
beena352 wants to merge 5 commits intomicrosoft:feature/wsl-for-appsfrom
beena352:user/beenachauhan/wslc-container-user-defined-networks

Conversation

@beena352
Copy link
Copy Markdown

Summary of the Pull Request

Add support for WSLCContainerNetworkTypeCustom, allowing containers to attach to user-created WSLC networks.

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

  • Uncommented WSLCContainerNetworkTypeCustom = 3 in wslc.idl
  • Added HasNetwork() to WSLCSession for validating network existence before Docker calls
  • Extended ProcessPortMappings with a Custom branch that validates the network name, checks existence via HasNetwork, and sets the network mode to the custom name. Custom networks allocate VM ports like bridged
  • DockerNetworkModeToWSLCNetworkType now returns Custom for unrecognized modes instead of throwing, so container recovery works for custom networks
  • Recovery port loop extended to allocate ports for Custom alongside Bridged

Validation Steps Performed

Copilot AI review requested due to automatic review settings April 24, 2026 18:12
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

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for WSLCContainerNetworkTypeCustom so containers can attach to user-created WSLC networks, including validation and port allocation behavior consistent with bridged networking.

Changes:

  • Enables WSLCContainerNetworkTypeCustom in the IDL and wires network name through the launcher/options path.
  • Adds WSLCSession::HasNetwork() and uses it to validate custom network existence before container creation.
  • Extends port mapping + recovery logic to allocate VM ports for Custom, and adds tests for custom network behavior/error cases.

Reviewed changes

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

Show a summary per file
File Description
test/windows/WSLCTests.cpp Adds coverage for launching containers on a custom network and validates error cases.
src/windows/wslcsession/WSLCSession.h Declares HasNetwork() helper used for custom network validation.
src/windows/wslcsession/WSLCSession.cpp Implements HasNetwork() with locking around cached networks.
src/windows/wslcsession/WSLCContainer.cpp Adds custom network branch in port mapping, changes Docker mode parsing behavior, and allocates recovery ports for custom networks.
src/windows/service/inc/wslc.idl Enables WSLCContainerNetworkTypeCustom = 3.
src/windows/common/WSLCContainerLauncher.h Adds API to set custom network name and stores it.
src/windows/common/WSLCContainerLauncher.cpp Propagates container network name into options passed to container creation.
localization/strings/en-US/Resources.resw Adds user-facing localized string for missing custom network name validation.

Comment thread src/windows/wslcsession/WSLCContainer.cpp Outdated
Comment thread src/windows/wslcsession/WSLCSession.h Outdated
Comment thread test/windows/WSLCTests.cpp
Comment thread src/windows/wslcsession/WSLCContainer.cpp Outdated
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 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslcsession/WSLCContainer.cpp
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 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread src/windows/wslcsession/WSLCSession.h Outdated
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 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread localization/strings/en-US/Resources.resw Outdated
@beena352 beena352 marked this pull request as ready for review April 24, 2026 20:58
@beena352 beena352 requested a review from a team as a code owner April 24, 2026 20:58
Copilot AI review requested due to automatic review settings April 24, 2026 20:58
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 8 out of 8 changed files in this pull request and generated no new comments.

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.

2 participants