How microsoft/wsl works
WSL runs Linux command-line tools and applications on Windows, with Linux distributions hosted by the Windows-side service and initialized by Linux-side runtime code. A distinct product branch, wslc, provides container, image, network, volume, registry, and session commands; its session path is shown where source excerpts establish the calls. The tree also contains the Linux 9P filesystem server and guest networking components. Several runtime connections and wslc command-to-service links are not demonstrated by the available excerpts, so they are not asserted.
Main entry points: ServiceMain.cpp WSL service · WSLCSessionManager.cpp Session manager · NetworkManager.cpp Guest networking · Main.cpp wslc command parser
Components 20
Windows host runtime
- WSL command
src/windows/wsl/main.cpp - WSL service
src/windows/service/exe/ServiceMain.cpp - Distribution registration
src/windows/service/exe/DistributionRegistration.cpp - Virtual machine
src/windows/service/exe/HcsVirtualMachine.cpp - User settings
src/windows/common/wslc/settings/WSLCUserSettings.cpp - Session manager
src/windows/service/exe/WSLCSessionManager.cpp - Plugin manager
src/windows/service/exe/PluginManager.cpp
Linux distribution runtime
- Linux init
src/linux/init/main.cpp - Guest networking
src/linux/init/NetworkManager.cpp - GNS notifications
src/linux/init/GnsEngine.cpp - 9P filesystem server
src/linux/plan9/p9handler.cpp - Netlink operations
src/linux/netlinkutil/IpNeighborManager.cpp
wslc container CLI
- wslc command parser
src/windows/wslc/core/Main.cpp - Resource commands
src/windows/wslc/commands - Session tasks
src/windows/wslc/tasks/SessionTasks.cpp - Session service
src/windows/wslc/services/SessionService.cpp - Resource services
src/windows/wslc/services
Shared runtime protocols
- Init message protocol
src/shared/inc/lxinitshared.h
Other components
- Windows user
- wslc user
Connections 12
- Windows user → WSL command: runs command
README.md - Linux init → Init message protocol: uses protocol
src/linux/init/main.cpp - GNS notifications → Guest networking: uses manager
- Guest networking → Netlink operations: manages neighbors
- wslc user → wslc command parser: runs command
- wslc command parser → Resource commands: dispatches commands
- Resource commands → Resource services: uses services
- Session tasks → Session service: calls
src/windows/wslc/tasks/SessionTasks.cpp - Session service → Session manager: creates manager
src/windows/wslc/services/SessionService.cpp - Session manager → Plugin manager: notifies plugins
src/windows/service/exe/WSLCSessionManager.cpp - WSL service → Distribution registration: registers distributions
- WSL service → Virtual machine: hosts Linux