Skip to content

Commit 2bc8f2c

Browse files
committed
RHEL-50142: Add IO limits to the Windows Guest debugging tools
Signed-off-by: Vitalii Chulak <vitalii@daynix.com>
1 parent b7b94a0 commit 2bc8f2c

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

Tools/debug/CollectSystemInfo.ps1

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,75 @@ function Export-EventLogs {
8888
}
8989
}
9090

91+
function Ensure-DiskSpd {
92+
$scriptDir = $null
93+
try {
94+
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
95+
} catch {}
96+
if (-not $scriptDir -or $scriptDir -eq '' -or -not (Test-Path $scriptDir)) {
97+
$scriptDir = (Get-Location).Path
98+
}
99+
100+
$diskspdExe = Join-Path $scriptDir 'diskspd.exe'
101+
$zipPath = Join-Path $scriptDir 'DiskSpd.ZIP'
102+
$extractDir = Join-Path $scriptDir 'DiskSpdExtracted'
103+
104+
if (-not (Test-Path $diskspdExe)) {
105+
if (-not (Test-Path $zipPath)) {
106+
Write-Warning "DiskSpd.zip not found. Please place it next to the script."
107+
return $null
108+
}
109+
Expand-Archive -Path $zipPath -DestinationPath $extractDir -Force
110+
111+
$arch = $env:PROCESSOR_ARCHITECTURE
112+
switch ($arch.ToLower()) {
113+
"amd64" { $subdir = "amd64" }
114+
"arm64" { $subdir = "arm64" }
115+
"x86" { $subdir = "x86" }
116+
"x86_64" { $subdir = "amd64" }
117+
"ia64" { $subdir = "amd64" }
118+
default { $subdir = "amd64"; Write-Host "DEBUG: Unknown arch '$arch', defaulting to amd64" }
119+
}
120+
Write-Host "DEBUG: subdir is '$subdir'"
121+
122+
$diskspdSource = Get-ChildItem -Path $extractDir -Recurse -Filter "diskspd.exe" | Where-Object { $_.FullName -like "*\$subdir\*" } | Select-Object -First 1
123+
124+
if ($diskspdSource) {
125+
Copy-Item $diskspdSource.FullName $diskspdExe -Force
126+
} else {
127+
Write-Warning "Could not find diskspd.exe for platform $arch in $extractDir."
128+
return $null
129+
}
130+
}
131+
return $diskspdExe
132+
}
133+
134+
function Export-IOLimits {
135+
try {
136+
$diskspdExe = Ensure-DiskSpd
137+
if (-not $diskspdExe) {
138+
Write-Warning "diskspd.exe not available. Skipping IO Limits collection."
139+
return
140+
}
141+
$lunDisks = Get-Disk
142+
foreach ($disk in $lunDisks) {
143+
$diskNumber = $disk.Number
144+
$partitions = Get-Partition -DiskNumber $diskNumber | Where-Object { $_.DriveLetter }
145+
foreach ($partition in $partitions) {
146+
$diskLetter = $partition.DriveLetter
147+
$outputFile = Join-Path $logfolderPath "IO_results_$diskLetter.txt"
148+
$testFile = "$diskLetter`:\test.dat"
149+
$result = & $diskspdExe -b1M -d30 -o32 -t4 -W -r -L -w0 -c512M $testFile 2>&1 | Tee-Object -FilePath $outputFile
150+
Remove-Item -Path $testFile -ErrorAction SilentlyContinue
151+
$output = "Disk Letter: $diskLetter, DiskSpd output: $outputFile"
152+
$output | Out-File -FilePath (Join-Path $logfolderPath 'IOLimits.txt') -Append
153+
}
154+
}
155+
} catch {
156+
Write-Warning "Failed to collect IO Limits: $_"
157+
}
158+
}
159+
91160
function Export-DriversList {
92161
try {
93162
Get-WindowsDriver -Online -All | Select-Object -Property * | Export-Csv -Path (Join-Path $logfolderPath 'drv_list.csv') -NoTypeInformation
@@ -276,6 +345,7 @@ Write-Output "Log folder path: $logfolderPath"
276345
try {
277346
Start-Transcript -Path $progressFile -Append
278347
$transcriptStarted = $true
348+
Export-IOLimits
279349
Export-SystemConfiguration
280350
Export-EventLogs
281351
Export-DriversList

Tools/debug/DiskSpd.ZIP

4.9 MB
Binary file not shown.

0 commit comments

Comments
 (0)