Skip to content

Conversation

@ptrivedi
Copy link

  • Add container network type to container options

  • Create containers with the specified network mode option

  • Currently supported network modes:
    - Host
    - None

    Bridge network mode will be added when the VHD is ready
    Custom network mode will be added at a later time
    

@ptrivedi ptrivedi requested a review from a team as a code owner December 12, 2025 17:22
@ptrivedi ptrivedi changed the base branch from master to feature/wsl-for-apps December 12, 2025 17:23
@ptrivedi ptrivedi requested a review from a team as a code owner December 12, 2025 17:23
Copy link
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 implements container network mode support for WSLA containers, enabling users to specify network configurations when creating containers. The implementation adds network type options to the container API, updates the nerdctl command generation to pass appropriate network flags, and includes the Stop() method implementation for container lifecycle management. The changes also include a mutex type upgrade from std::mutex to std::recursive_mutex to support nested locking patterns.

Key changes:

  • Added WSLA_CONTAINER_NETWORK_TYPE enum and WSLA_CONTAINER_NETWORK struct to container options
  • Implemented network mode handling for Host and None modes (Bridge mode pending VHD updates)
  • Implemented the previously stubbed Stop() method for container lifecycle management

Reviewed changes

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

Show a summary per file
File Description
src/windows/wslaservice/inc/wslaservice.idl Added WSLA_CONTAINER_NETWORK_TYPE enum and WSLA_CONTAINER_NETWORK struct to define container network configuration options
src/windows/wslaservice/exe/WSLAContainer.h Changed m_lock from std::mutex to std::recursive_mutex to support nested locking when State() is called from locked methods
src/windows/wslaservice/exe/WSLAContainer.cpp Implemented network mode handling in PrepareNerdctlCreateCommand() and implemented Stop() method for container lifecycle management
src/windows/common/WSLAProcessLauncher.h Added FormatResult(int) overload declaration for formatting exit codes without full process output
src/windows/common/WSLAProcessLauncher.cpp Implemented FormatResult(int) overload for Stop() method error messages
src/windows/common/WSLAContainerLauncher.h Added containerNetworkType parameter to constructor and m_containerNetworkType member variable
src/windows/common/WSLAContainerLauncher.cpp Updated constructor and LaunchNoThrow() to pass network type to container options
test/windows/WSLATests.cpp Updated all container test cases with network type parameter and added ContainerNetwork test method to validate network mode functionality

const std::string& EntryPoint,
const std::vector<std::string>& Arguments,
const std::vector<std::string>& Environment,
int containerNetworkType,
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The parameter name 'containerNetworkType' uses camelCase which is inconsistent with other parameter names in this constructor that use PascalCase (Image, Name, EntryPoint, Arguments, Environment, Flags). It should be renamed to 'ContainerNetworkType' for consistency.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

const std::string& EntryPoint = "",
const std::vector<std::string>& Arguments = {},
const std::vector<std::string>& Environment = {},
int containerNetworkType = 1,
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The parameter name 'containerNetworkType' uses camelCase which is inconsistent with other parameter names in this function declaration that use PascalCase (Image, Name, EntryPoint, Arguments, Environment, Flags). It should be renamed to 'ContainerNetworkType' for consistency.

Suggested change
int containerNetworkType = 1,
int ContainerNetworkType = 1,

Copilot uses AI. Check for mistakes.
private:
std::string m_image;
std::string m_name;
int m_containerNetworkType;
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The member variable type should be 'WSLA_CONTAINER_NETWORK_TYPE' instead of 'int' for type safety and consistency with the struct field it's assigned to.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

* Add container network type to container options
* Create containers with the specified network mode option
* Currently supported network modes:
  - Host
  - None

  Bridge network mode will be added when the VHD is ready
  Custom network mode will be added at a later time
@ptrivedi ptrivedi force-pushed the user/ptrivedi/cont-network-mode branch from 1a7785b to 7286ff9 Compare December 12, 2025 17:30
Copy link
Contributor

Copilot AI commented Dec 15, 2025

@ptrivedi I've opened a new pull request, #13911, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Dec 15, 2025

@ptrivedi I've opened a new pull request, #13912, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Dec 15, 2025

@ptrivedi I've opened a new pull request, #13913, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Dec 15, 2025

@ptrivedi I've opened a new pull request, #13915, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Dec 15, 2025

@ptrivedi I've opened a new pull request, #13916, to work on those changes. Once the pull request is ready, I'll request review from you.

@ptrivedi ptrivedi force-pushed the user/ptrivedi/cont-network-mode branch from 9691a2a to 41776f6 Compare December 15, 2025 19:50
@ptrivedi ptrivedi force-pushed the user/ptrivedi/cont-network-mode branch 2 times, most recently from dc8946a to 87b7671 Compare December 15, 2025 20:01
@ptrivedi ptrivedi force-pushed the user/ptrivedi/cont-network-mode branch from 87b7671 to 606dc8d Compare December 15, 2025 20:08
@OneBlue OneBlue merged commit fbe4450 into feature/wsl-for-apps Dec 15, 2025
6 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.

4 participants