Skip to content

Commit 513b64c

Browse files
authored
Merge branch 'microsoft:master' into fix/suppress-getaddrinfo-nodata-error
2 parents a0a3e55 + 4b23185 commit 513b64c

23 files changed

Lines changed: 930 additions & 1189 deletions

.github/copilot-instructions.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ python3 distributions/validate.py distributions/DistributionInfo.json
173173
wpr -start diagnostics\wsl.wprp -filemode
174174
# [reproduce issue]
175175
wpr -stop logs.ETL
176+
177+
# Available profiles:
178+
# - WSL (default) - General WSL tracing
179+
# - WSL-Storage - Enhanced storage tracing
180+
# - WSL-Networking - Comprehensive networking tracing
181+
# - WSL-HvSocket - HvSocket-specific tracing
182+
# Example: wpr -start diagnostics\wsl.wprp!WSL -filemode
176183
```
177184

178185
### Log Analysis Tools

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ Set-ExecutionPolicy Bypass -Scope Process -Force
7979
```
8080
The script will output the path of the log file once done.
8181

82+
For specific scenarios, you can use different log profiles:
83+
- `.\collect-wsl-logs.ps1 -LogProfile storage` - Enhanced storage tracing
84+
- `.\collect-wsl-logs.ps1 -LogProfile networking` - Networking-focused tracing
85+
- `.\collect-wsl-logs.ps1 -LogProfile hvsocket` - HvSocket-specific tracing
86+
- `.\collect-networking-logs.ps1` - Alternative script for networking tracing
87+
8288
### 10) Reporting a Windows crash (BSOD)
8389

8490
To collect a kernel crash dump, first run the following command in an elevated command prompt:

UserConfig.cmake.sample

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,36 @@
22

33
message(STATUS "Loading user configuration")
44

5-
# # Uncomment to enable development packages (smaller, faster to install)
6-
# # Note: system.vhd fails to mount if symlink / hardlink, so COPY is needed.
5+
# Uncomment to enable development packages (smaller, faster to install)
6+
# # Note: .vhd files fail to mount via symlink / hardlink, so COPY is needed.
77
# set(WSL_DEV_BINARY_PATH "C:/wsldev")
8-
# file(MAKE_DIRECTORY ${WSL_DEV_BINARY_PATH})
9-
# file(CREATE_LINK "${KERNEL_SOURCE_DIR}/bin/${TARGET_PLATFORM}/kernel" "${WSL_DEV_BINARY_PATH}/kernel" SYMBOLIC)
10-
# file(COPY_FILE "${WSLG_SOURCE_DIR}/${TARGET_PLATFORM}/system.vhd" "${WSL_DEV_BINARY_PATH}/system.vhd" ONLY_IF_DIFFERENT)
11-
# file(COPY_FILE "${KERNEL_SOURCE_DIR}/bin/${TARGET_PLATFORM}/modules.vhd" "${WSL_DEV_BINARY_PATH}/modules.vhd" ONLY_IF_DIFFERENT)
12-
# file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/msrdc.exe" "${WSL_DEV_BINARY_PATH}/msrdc.exe" SYMBOLIC)
13-
# file(CREATE_LINK "${WSLG_SOURCE_DIR}/wslg.rdp" "${WSL_DEV_BINARY_PATH}/wslg.rdp" SYMBOLIC)
14-
# file(CREATE_LINK "${WSLG_SOURCE_DIR}/wslg_desktop.rdp" "${WSL_DEV_BINARY_PATH}/wslg_desktop.rdp" SYMBOLIC)
15-
# file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/rdclientax.dll" "${WSL_DEV_BINARY_PATH}/rdclientax.dll" SYMBOLIC)
16-
# file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/rdpnanoTransport.dll" "${WSL_DEV_BINARY_PATH}/rdpnanoTransport.dll" SYMBOLIC)
17-
# file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/RdpWinStlHelper.dll" "${WSL_DEV_BINARY_PATH}/RdpWinStlHelper.dll" SYMBOLIC)
18-
# file(CREATE_LINK "${MSAL_SOURCE_DIR}/${TARGET_PLATFORM}/msal.wsl.proxy.exe" "${WSL_DEV_BINARY_PATH}/msal.wsl.proxy.exe" SYMBOLIC)
19-
# file(CREATE_LINK "${BIN}/wsldevicehost.dll" "${WSL_DEV_BINARY_PATH}/wsldevicehost.dll" SYMBOLIC)
20-
# file(CREATE_LINK "${DIRECT3D_SOURCE_DIR}/lib/${TARGET_PLATFORM}" "${WSL_DEV_BINARY_PATH}/lib" SYMBOLIC)
21-
22-
# foreach(LANG ${SUPPORTED_LANGS})
23-
# file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/${LANG}" "${WSL_DEV_BINARY_PATH}/${LANG}" SYMBOLIC)
24-
# endforeach()
8+
9+
if(WSL_DEV_BINARY_PATH)
10+
file(MAKE_DIRECTORY ${WSL_DEV_BINARY_PATH})
11+
file(CREATE_LINK "${KERNEL_SOURCE_DIR}/bin/${TARGET_PLATFORM}/kernel" "${WSL_DEV_BINARY_PATH}/kernel" SYMBOLIC)
12+
file(COPY_FILE "${WSLG_SOURCE_DIR}/${TARGET_PLATFORM}/system.vhd" "${WSL_DEV_BINARY_PATH}/system.vhd" ONLY_IF_DIFFERENT)
13+
file(COPY_FILE "${KERNEL_SOURCE_DIR}/bin/${TARGET_PLATFORM}/modules.vhd" "${WSL_DEV_BINARY_PATH}/modules.vhd" ONLY_IF_DIFFERENT)
14+
15+
# read-only VHDs need to be world readable to mount successfully.
16+
execute_process(
17+
COMMAND icacls.exe "${WSL_DEV_BINARY_PATH}/system.vhd" "/grant:r" "Everyone:(R)" /Q
18+
COMMAND icacls.exe "${WSL_DEV_BINARY_PATH}/modules.vhd" "/grant:r" "Everyone:(R)" /Q
19+
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
20+
COMMAND_ERROR_IS_FATAL ANY)
21+
22+
file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/msrdc.exe" "${WSL_DEV_BINARY_PATH}/msrdc.exe" SYMBOLIC)
23+
file(CREATE_LINK "${WSLG_SOURCE_DIR}/wslg.rdp" "${WSL_DEV_BINARY_PATH}/wslg.rdp" SYMBOLIC)
24+
file(CREATE_LINK "${WSLG_SOURCE_DIR}/wslg_desktop.rdp" "${WSL_DEV_BINARY_PATH}/wslg_desktop.rdp" SYMBOLIC)
25+
file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/rdclientax.dll" "${WSL_DEV_BINARY_PATH}/rdclientax.dll" SYMBOLIC)
26+
file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/rdpnanoTransport.dll" "${WSL_DEV_BINARY_PATH}/rdpnanoTransport.dll" SYMBOLIC)
27+
file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/RdpWinStlHelper.dll" "${WSL_DEV_BINARY_PATH}/RdpWinStlHelper.dll" SYMBOLIC)
28+
file(CREATE_LINK "${MSAL_SOURCE_DIR}/${TARGET_PLATFORM}/msal.wsl.proxy.exe" "${WSL_DEV_BINARY_PATH}/msal.wsl.proxy.exe" SYMBOLIC)
29+
file(CREATE_LINK "${DIRECT3D_SOURCE_DIR}/lib/${TARGET_PLATFORM}" "${WSL_DEV_BINARY_PATH}/lib" SYMBOLIC)
30+
31+
foreach(LANG ${SUPPORTED_LANGS})
32+
file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/${LANG}" "${WSL_DEV_BINARY_PATH}/${LANG}" SYMBOLIC)
33+
endforeach()
34+
endif()
2535

2636
# # Uncomment to skip building, packaging and installing wslsettings
2737
# set(WSL_BUILD_WSL_SETTINGS false)

diagnostics/collect-networking-logs.ps1

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,23 @@ function Collect-WindowsNetworkState {
124124
$folder = "WslNetworkingLogs-" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss")
125125
mkdir -p $folder
126126

127-
$logProfile = "$folder/wsl_networking.wprp"
127+
$wprpFile = "$folder/wsl.wprp"
128+
$wprpProfile = "WSL-Networking"
128129
$networkingBashScript = "$folder/networking.sh"
129130

130131
# Detect the super user first.
131132
# Actually it's not definite that the super user is named "root". Instead, a user with uid=0 is what we are looking for. See #11693.
132133
$superUser = & wsl.exe -- id -nu 0 # user name of the super user.
133134

134135
# Copy/Download supporting files
135-
if (Test-Path "$PSScriptRoot/wsl_networking.wprp")
136+
if (Test-Path "$PSScriptRoot/wsl.wprp")
136137
{
137-
Copy-Item "$PSScriptRoot/wsl_networking.wprp" $logProfile
138+
Copy-Item "$PSScriptRoot/wsl.wprp" $wprpFile
138139
}
139140
else
140141
{
141-
Write-Host -ForegroundColor Yellow "wsl_networking.wprp not found in the current directory. Downloading it from GitHub."
142-
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_networking.wprp" -OutFile $logProfile
142+
Write-Host -ForegroundColor Yellow "wsl.wprp not found in the current directory. Downloading it from GitHub."
143+
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp" -OutFile $wprpFile
143144
}
144145

145146
if (Test-Path "$PSScriptRoot/networking.sh")
@@ -183,13 +184,13 @@ if ($RestartWslReproMode)
183184
# Start logging.
184185
$wprOutputLog = "$folder/wpr.txt"
185186

186-
wpr.exe -start $logProfile -filemode 2>&1 >> $wprOutputLog
187+
wpr.exe -start "$wprpFile!$wprpProfile" -filemode 2>&1 >> $wprOutputLog
187188
if ($LastExitCode -Ne 0)
188189
{
189190
Write-Host -ForegroundColor Yellow "Log collection failed to start (exit code: $LastExitCode), trying to reset it."
190191
wpr.exe -cancel 2>&1 >> $wprOutputLog
191192

192-
wpr.exe -start $logProfile -filemode 2>&1 >> $wprOutputLog
193+
wpr.exe -start "$wprpFile!$wprpProfile" -filemode 2>&1 >> $wprOutputLog
193194
if ($LastExitCode -Ne 0)
194195
{
195196
Write-Host -ForegroundColor Red "Couldn't start log collection (exitCode: $LastExitCode)"
@@ -309,7 +310,7 @@ if (Test-Path $setupApiPath)
309310
Copy-Item $setupApiPath $folder
310311
}
311312

312-
Remove-Item $logProfile
313+
Remove-Item $wprpFile
313314
Remove-Item $networkingBashScript
314315

315316
$logArchive = "$(Resolve-Path $folder).zip"

diagnostics/collect-wsl-logs.ps1

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,44 @@ Set-StrictMode -Version Latest
1111
$folder = "WslLogs-" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss")
1212
mkdir -p $folder | Out-Null
1313

14-
if ($LogProfile -eq $null -Or ![System.IO.File]::Exists($LogProfile))
14+
# Check if LogProfile is a custom file path or a profile name
15+
if ($LogProfile -ne $null -And [System.IO.File]::Exists($LogProfile))
1516
{
16-
if ($LogProfile -eq $null)
17+
# User provided a custom .wprp file path - use it directly
18+
$wprpFile = $LogProfile
19+
$wprpProfile = $null # Use default profile in the file
20+
}
21+
else
22+
{
23+
# Map log profile names to WPRP profile names
24+
$wprpProfile = "WSL"
25+
if ($LogProfile -eq "storage")
1726
{
18-
$url = "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp"
27+
$wprpProfile = "WSL-Storage"
1928
}
20-
elseif ($LogProfile -eq "storage")
29+
elseif ($LogProfile -eq "networking")
2130
{
22-
$url = "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_storage.wprp"
31+
$wprpProfile = "WSL-Networking"
2332
}
2433
elseif ($LogProfile -eq "hvsocket")
2534
{
26-
$url = "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_hvsocket.wprp"
35+
$wprpProfile = "WSL-HvSocket"
2736
}
28-
else
37+
elseif ($LogProfile -ne $null)
2938
{
30-
Write-Error "Unknown log profile: $LogProfile"
39+
Write-Error "Unknown log profile: $LogProfile. Valid options are: storage, networking, hvsocket, or a path to a custom .wprp file"
3140
exit 1
3241
}
3342

34-
$LogProfile = "$folder/wsl.wprp"
35-
try {
36-
Invoke-WebRequest -UseBasicParsing $url -OutFile $LogProfile
43+
# Use the consolidated wsl.wprp file, attempt to use local copy first.
44+
$wprpFile = "$folder/wsl.wprp"
45+
if (Test-Path "$PSScriptRoot/wsl.wprp")
46+
{
47+
Copy-Item "$PSScriptRoot/wsl.wprp" $wprpFile
3748
}
38-
catch {
39-
throw
49+
else
50+
{
51+
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp" -OutFile $wprpFile
4052
}
4153
}
4254

@@ -71,13 +83,23 @@ if (Test-Path $uninstallLogs)
7183

7284
$wprOutputLog = "$folder/wpr.txt"
7385

74-
wpr.exe -start $LogProfile -filemode 2>&1 >> $wprOutputLog
86+
# Build wpr command - if wprpProfile is set, use profile syntax, otherwise use file only
87+
if ($wprpProfile -ne $null)
88+
{
89+
$wprCommand = "$wprpFile!$wprpProfile"
90+
}
91+
else
92+
{
93+
$wprCommand = $wprpFile
94+
}
95+
96+
wpr.exe -start $wprCommand -filemode 2>&1 >> $wprOutputLog
7597
if ($LastExitCode -Ne 0)
7698
{
7799
Write-Host -ForegroundColor Yellow "Log collection failed to start (exit code: $LastExitCode), trying to reset it."
78100
wpr.exe -cancel 2>&1 >> $wprOutputLog
79101

80-
wpr.exe -start $LogProfile -filemode 2>&1 >> $wprOutputLog
102+
wpr.exe -start $wprCommand -filemode 2>&1 >> $wprOutputLog
81103
if ($LastExitCode -Ne 0)
82104
{
83105
Write-Host -ForegroundColor Red "Couldn't start log collection (exitCode: $LastExitCode)"

0 commit comments

Comments
 (0)