project-pegaprox icon indicating copy to clipboard operation
project-pegaprox copied to clipboard

[Bug] Offline VirtIO injection writes BusType=1 for vioscsi — the vendor INF says 0x0A — and registers DEV_1041 (VirtIO network) as its device id, so a guest moved to VirtIO SCSI stops with INACCESSIBLE_BOOT_DEVICE

Open Frisch12 opened this issue 2 months ago • 2 comments

Describe the bug

_inject_virtio_drivers (pegaprox/core/v2p.py:2123) registers both storage drivers with the same BusType:

# v2p.py:2414-2425
if have_viostor: _svcs.append(('viostor', 0x58, 'system32\\drivers\\viostor.sys'))
if have_vioscsi: _svcs.append(('vioscsi', 0x59, 'system32\\drivers\\vioscsi.sys'))
for svc, tag, img in _svcs:
    ...
    params = navigate(svc_node, ['Parameters'])
    set_dword(params, 'BusType', 1)

The value is not the same for both drivers. Read from the vendor INF files:

driver HKR, "Parameters", "BusType" DmaRemappingCompatible source
viostor.inf 0x00000001 0 viostor/viostor.inx:93-94
vioscsi.inf 0x0000000A 0 vioscsi/vioscsi.inx:94-95

So viostor is right and vioscsi is wrong — and vioscsi is the driver that matters, because VirtIO SCSI is what scsihw: virtio-scsi-single produces and what the Proxmox documentation recommends. A guest whose boot disk is moved to VirtIO Block boots; one moved to VirtIO SCSI stops with INACCESSIBLE_BOOT_DEVICE. DmaRemappingCompatible, which both INFs set, is not written at all.

Measured on one Windows Server 2022 image (build 20348), injected by the product, disk switched to scsi0 on virtio-scsi-single, nothing else changed between the two runs:

Parameters\BusType for vioscsi what the guest does
1 (current) INACCESSIBLE_BOOT_DEVICE before usermode
0x0A + DmaRemappingCompatible=0 the Windows loader runs and reads its disk over vioscsi

This is not version-specific

Every vioscsi.inf on the current virtio-win ISO (DriverVer 07/22/2026, 100.103.104.30200) was read — all thirteen variants it ships:

2k8  2k8R2  2k12  2k12R2  2k16  2k19  2k22  2k25  w7  w8  w8.1  w10  w11

All of them write BusType = 0x0000000A, name the same two hardware IDs, and use SERVICE_BOOT_START with LoadOrderGroup = SCSI miniport. Every viostor.inf writes 0x00000001. There is no Windows version for which writing 1 for vioscsi is right; this is a per-driver value, not a per-version one.

A second defect in the same block: the wrong device id

# v2p.py:2433-2436
if have_vioscsi:
    _pci += [('pci#ven_1af4&dev_1004', 'vioscsi'),
             ('pci#ven_1af4&dev_1004&subsys_00081af4', 'vioscsi'),
             ('pci#ven_1af4&dev_1041', 'vioscsi')]

DEV_1041 is VirtIO network (it is what netkvm.inf matches). vioscsi.inx:52-53 names exactly two devices:

PCI\VEN_1AF4&DEV_1004&SUBSYS_0008…&REV_00, PCI\VEN_1AF4&DEV_1004     ← transitional
PCI\VEN_1AF4&DEV_1048&SUBSYS_1100…&REV_01, PCI\VEN_1AF4&DEV_1048     ← modern

Which of the two a guest is given depends on the machine type the target VM was built with. On a pc machine with virtio-scsi-single the controller reports 1af4:1004, so there the wrong entry is merely dead; on a machine presenting the modern device, the entry that would have matched is missing.

Steps to Reproduce

  1. Import a powered-off Windows Server 2022 guest with install_virtio_drivers set, so the injection runs and reports INJECTION_OK.
  2. Attach the boot disk as scsi0 with scsihw: virtio-scsi-single.
  3. Start the guest.

Observed: INACCESSIBLE_BOOT_DEVICE, with everything else the injection writes verified correct in the hive beforehand — Services\vioscsi with Start=0, Type=1, Group='SCSI miniport' and the right ImagePath; vioscsi.sys in System32\drivers with a valid embedded Authenticode signature; three CriticalDeviceDatabase entries; Select\Current = 1, so ControlSet001 is the set being written and read; no hiberfil.sys. Five other explanations were measured and ruled out before the INF was read.

Expected behavior

The guest's loader can read its disk over VirtIO SCSI, instead of stopping before usermode.

Carry the value per driver rather than once for both, and write the second value the INFs set:

if have_viostor: _svcs.append(('viostor', 0x58, 'system32\\drivers\\viostor.sys', 0x01))
if have_vioscsi: _svcs.append(('vioscsi', 0x59, 'system32\\drivers\\vioscsi.sys', 0x0A))
for svc, tag, img, bus_type in _svcs:
    ...
    set_dword(params, 'BusType', bus_type)
    set_dword(params, 'DmaRemappingCompatible', 0)

and replace dev_1041 with dev_1048 (plus its subsys_11001af4&rev_01 form) in the CriticalDeviceDatabase list.

Scope, so this is not read as more than it is. Fixing BusType turns a bluescreen into a loader that runs and reads its disk. It does not by itself produce a guest that boots all the way: with only this fixed, Server 2016, 2022 and 2025 stop in the recovery environment, and the same disks moved back to SATA boot to the login screen unchanged. The reason is that the injection registers the boot driver only in the CriticalDeviceDatabase, which Windows 8 and newer no longer read — a separate report. With both in place the same images reach the login screen on VirtIO SCSI within a minute:

vioscsi registration Server 2016 / 2022 / 2025 on virtio-scsi-single
BusType=1 (current) INACCESSIBLE_BOOT_DEVICE
BusType=0x0A loader runs, reads the disk, stops in the recovery environment
BusType=0x0A + DriverDatabase entries (separate report) login screen after one minute

More generally: these values are in the INF files that ship beside the drivers, and reading them at injection time rather than hard-coding them would keep this correct when the drivers change.

The fix is implemented and tested on our side, with tests that fail when the value is lost. Happy to open a PR against Testing with it.

Environment

  • PegaProx Version: 1.1.1 (v2p.py unchanged on Testing)
  • Installation Method: Manual (git clone), PegaProx on Debian 13 / Python 3.13
  • OS: target node Proxmox VE 9.2.11, kernel 6.17.9-1-pve
  • Guest: Windows Server 2022 Standard, build 20348, Generation 1 / seabios / pc; the scope table adds Server 2016 (14393) and 2025 (26100), fresh unattended installs
  • virtio-win ISO: DriverVer 07/22/2026, 100.103.104.30200
  • Browser: n/a — reproduced through the migration runner, not the UI
  • Behind Reverse Proxy? No
  • UI? n/a

Logs

The injection reports success in the failing case; the symptom is on the guest's screen, not in the log.

HIVEX have_viostor=True have_vioscsi=True
hivex commit OK
INJECTION_OK
[VirtIO] ✓ Drivers staged + registry merged.
[VirtIO]   scsihw left untouched — switch manually after first boot if desired

Guest, after the switch to virtio-scsi-single:

Stop code: INACCESSIBLE_BOOT_DEVICE

Screenshots

Not applicable — the stop code above is the whole screen.

Checklist

  • [x] I have searched existing issues to make sure this is not a duplicate
  • [x] I am using the latest version of PegaProx
  • [x] I've put enough in here that someone can start on it without asking me three questions first
  • [x] I understand PegaProx is maintained by volunteers in their free time. Nobody is on call, and writing URGENT doesn't get anyone out of bed 🪄

– Dennis

Frisch12 avatar Sep 15 '26 08:09 Frisch12

Yes, please open it against Testing.

Two reasons I'd rather take your patch than write my own here. Your reading matches the numbering — modern virtio ids are 0x1040 + device type, so type 1 is net (1041, which is what's in there now) and type 8 is SCSI (1048) — so dev_1041 in the vioscsi list is simply wrong either way. And more to the point: you have Windows guests you can boot and I don't, so I can't verify the part that actually matters. Landing a three-line registry change I can only reason about isn't the same thing as one someone watched come up on VirtIO SCSI.

Keep the per-driver BusType shape you sketched and the DmaRemappingCompatible write. Reading the values out of the INF at injection time instead of hard-coding them is the better answer long-term, but don't hold the PR for it.

Marcus

mkellermann97 avatar Sep 15 '26 10:09 mkellermann97

The offline VirtIO injection now writes BusType 0x0A and DmaRemappingCompatible=0 for vioscsi, while viostor keeps 1. It also maps the real transitional and modern device ids instead of DEV_1041 and writes into the control set Select actually points at. As your scope note says, this gets the loader past INACCESSIBLE_BOOT_DEVICE but adds no DriverDatabase entries, so the switch to VirtIO SCSI is still manual. This ships in 1.3.0, and thanks for reading the INFs so carefully.

Marcus

mkellermann97 avatar Oct 07 '26 04:10 mkellermann97