bootstrap: install the vioser driver for the running Windows build

The recursive search returned vioserial/2k12 first (alphabetical), and
pnputil rejects it on Server 2022 with -536870325. The agent MSI installed
fine (exit 0) but never had a channel. Pick the folder from the OS build
and fall back through the other amd64 builds until one succeeds.
This commit is contained in:
2026-10-26 17:49:01 -04:00
parent 37852b3f0b
commit f0f5ffc140
+18 -8
View File
@@ -78,14 +78,24 @@ try {
# The agent MSI does not install the VirtIO serial driver. Without it # The agent MSI does not install the VirtIO serial driver. Without it
# the service starts but never connects to the channel, and Proxmox # the service starts but never connects to the channel, and Proxmox
# shows "guest agent is not running", which blocks provisioning. # shows "guest agent is not running", which blocks provisioning.
$vioser = Get-ChildItem "$($virtioRoot)vioserial" -Recurse -Filter 'vioser.inf' ` # Pick the driver for this Windows build first (2k12 first in the
-ErrorAction SilentlyContinue | # directory made pnputil reject it on Server 2022), then fall back to
Where-Object { $_.FullName -match 'amd64' } | Select-Object -First 1 # the other amd64 builds until one reports success.
if ($vioser) { $build = [Environment]::OSVersion.Version.Build
$null = pnputil.exe /add-driver $vioser.FullName /install $pref = '2k12'
Write-Host "bootstrap: vioser add-driver exit=$LASTEXITCODE ($($vioser.FullName))" if ($build -ge 26100) { $pref = '2k25' } elseif ($build -ge 20348) { $pref = '2k22' } elseif ($build -ge 17763) { $pref = '2k19' } elseif ($build -ge 14393) { $pref = '2k16' }
} else { $candidates = @($pref, '2k25', '2k22', 'w11', '2k19', '2k16', '2k12') |
Write-Host 'bootstrap: vioser.inf not found on the virtio CD' Select-Object -Unique
$driverOk = $false
foreach ($v in $candidates) {
$inf = Join-Path $virtioRoot "vioserial\$v\amd64\vioser.inf"
if (-not (Test-Path $inf)) { continue }
$null = pnputil.exe /add-driver $inf /install
Write-Host "bootstrap: vioser $v exit=$LASTEXITCODE"
if ($LASTEXITCODE -eq 0) { $driverOk = $true; break }
}
if (-not $driverOk) {
Write-Host 'bootstrap: no vioser driver could be installed'
} }
$msi = "$($virtioRoot)guest-agent\qemu-ga-x86_64.msi" $msi = "$($virtioRoot)guest-agent\qemu-ga-x86_64.msi"