diff --git a/session1/content/seed/payload/bootstrap.ps1 b/session1/content/seed/payload/bootstrap.ps1 index e0ae8a9..4684bde 100644 --- a/session1/content/seed/payload/bootstrap.ps1 +++ b/session1/content/seed/payload/bootstrap.ps1 @@ -78,14 +78,24 @@ try { # The agent MSI does not install the VirtIO serial driver. Without it # the service starts but never connects to the channel, and Proxmox # shows "guest agent is not running", which blocks provisioning. - $vioser = Get-ChildItem "$($virtioRoot)vioserial" -Recurse -Filter 'vioser.inf' ` - -ErrorAction SilentlyContinue | - Where-Object { $_.FullName -match 'amd64' } | Select-Object -First 1 - if ($vioser) { - $null = pnputil.exe /add-driver $vioser.FullName /install - Write-Host "bootstrap: vioser add-driver exit=$LASTEXITCODE ($($vioser.FullName))" - } else { - Write-Host 'bootstrap: vioser.inf not found on the virtio CD' + # Pick the driver for this Windows build first (2k12 first in the + # directory made pnputil reject it on Server 2022), then fall back to + # the other amd64 builds until one reports success. + $build = [Environment]::OSVersion.Version.Build + $pref = '2k12' + if ($build -ge 26100) { $pref = '2k25' } elseif ($build -ge 20348) { $pref = '2k22' } elseif ($build -ge 17763) { $pref = '2k19' } elseif ($build -ge 14393) { $pref = '2k16' } + $candidates = @($pref, '2k25', '2k22', 'w11', '2k19', '2k16', '2k12') | + 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"