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

[Bug] VirtIO injection on a Proxmox node: the apt step asks for qemu-utils and would take proxmox-ve with it, hivexsh is used but never installed so every guest gets the w11 driver variant, and driver catalogues are written where Windows never reads them

Open Frisch12 opened this issue 2 months ago • 2 comments

Describe the bug

_inject_virtio_drivers (pegaprox/core/v2p.py:2123) has three independent defects on a stock Proxmox VE node. All three were found in one run — one migration of a powered-off Windows Server 2022 guest with install_virtio_drivers set, onto a stock PVE 9.2.11 node — and all three have the same shape: the injection reports something other than what happened.

stock PVE 9.2.11 node, Windows Server 2022 guest (build 20348)
packages the one-time install asks for (v2p.py:2161-2162) python3-hivex ntfs-3g qemu-utils
what apt proposes to remove to satisfy qemu-utils pve-qemu-kvm, and with it proxmox-ve
what is installed after pve-apt-hook aborts the run nothing — python3-hivex and ntfs-3g fail alongside
reason shown in the migration log [VirtIO] ✗ apt install failed: — empty
VER_BUILD read by hivexsh on a node without libhivex-bin (empty) → SUBDIR=w11/amd64, INJECTION_OK
VER_BUILD with libhivex-bin present, same disk 20348 → SUBDIR=2k22/amd64
catalogues in System32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE} after injection 0 of 6
catalogues in System32\drivers 6 of 6

1. The one-time apt install asks for qemu-utils, which conflicts with pve-qemu-kvm

The tool probe and the install that follows it:

# pegaprox/core/v2p.py:2154
rc, _, _ = _pve_node_exec(pve_mgr, node,
    "python3 -c 'import hivex' 2>/dev/null && command -v ntfs-3g >/dev/null "
    "&& command -v ntfsfix >/dev/null && command -v qemu-nbd >/dev/null",
    timeout=10)
if rc != 0:
    task.log("[VirtIO] Installing python3-hivex / ntfs-3g / qemu-utils (one-time)...")
    rc_apt, out_apt, _ = _pve_node_exec(pve_mgr, node,
        "DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends "
        "python3-hivex ntfs-3g qemu-utils 2>&1 | tail -5",
        timeout=180)
    if rc_apt != 0:
        task.log(f"[VirtIO] ✗ apt install failed: {str(out_apt or '')[-200:]}")
        return False

On PVE, qemu-utils conflicts with pve-qemu-kvm. apt resolves that by proposing to remove pve-qemu-kvm and, with it, proxmox-ve. pve-apt-hook recognises the situation and aborts — which is the only reason the node survives, and also why nothing in the list gets installed. | tail -5 keeps the hook's message out of the captured output, so the operator sees an empty reason after the colon.

qemu-nbd was present the whole time: on PVE it ships with pve-qemu-kvm. The probe asked for it, found it, and the apt run happened only because another tool was missing — and then took the whole list down with it.

The same file already knows this. The qemu-img preflight rewritten for #520 (v2p.py:457-467) tells the operator: "Do NOT run apt install qemu-utils on PVE 9.x: that package conflicts with pve-qemu-kvm and can break the Proxmox install." That fix did not reach this call site, 1,700 lines further down.

2. hivexsh is used but never installed, so every guest gets the w11/amd64 driver variant

The script reads the guest's Windows version out of the SOFTWARE hive:

# v2p.py:2313-2322
VER_NAME=$(hivexsh "$SOFTWARE" <<HEOF 2>/dev/null
cd \Microsoft\Windows NT\CurrentVersion
lsval ProductName
HEOF
)
VER_BUILD=$(hivexsh "$SOFTWARE" <<HEOF 2>/dev/null
cd \Microsoft\Windows NT\CurrentVersion
lsval CurrentBuildNumber
HEOF
)

hivexsh comes from libhivex-bin, which is not a PVE dependency and is in neither the probe nor the install list. On a stock node the command is absent, 2>/dev/null hides that, both variables come back empty, the build-number table (v2p.py:2328-2345) matches nothing, and the *) branch selects w11/amd64. The injection logs SUBDIR=w11/amd64, copies that variant in, and finishes with INJECTION_OK.

Measured on the same Windows Server 2022 disk with the same ISO:

libhivex-bin on the node VER_BUILD SUBDIR
absent (empty) w11/amd64
present 20348 2k22/amd64

The dependency was known once: the module header (v2p.py:2077) lists libhivex-bin (hivexregedit) among the tools needed, and the comment at v2p.py:2149 explains that hivexregedit is not in Debian's package and python3-hivex does the registry merge instead. What was lost in between is that the version probe still needs the package, for hivexsh.

3. Driver catalogues are copied next to the .sys, where nothing reads them

# v2p.py:2352, 2365
DRV_DEST="$WIN_MNT/$WDIR/System32/drivers"
...
cp -f "$SRC"/*.cat "$DRV_DEST/" 2>/dev/null||true

Windows reads driver catalogues from System32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}, not from the directory holding the driver binary. On the injected guest, that store contained none of the six catalogues the injection had copied (balloon, netkvm, viorng, vioscsi, vioser, viostor), while System32\drivers held all six.

What this finding is not: it is not the reason an injected guest fails to boot on VirtIO SCSI. That was tested directly — the catalogues were moved into the store by hand and the guest stopped with INACCESSIBLE_BOOT_DEVICE exactly as before, and again with nointegritychecks and testsigning on. vioscsi.sys carries an embedded Authenticode signature, so the boot-time check does not need the store. The reason the guest does not boot is a separate report (the boot driver is registered only in the CriticalDeviceDatabase, which Windows 8 and newer no longer read). This finding is about the file being where Windows expects it once the staged INF is installed.

Steps to Reproduce

  1. Stock PVE 9.2.11 node: no libhivex-bin, no python3-hivex, no ntfs-3g.
  2. Import a powered-off Windows Server 2022 guest onto it with its boot disk on sata0.
  3. Run the migration with install_virtio_drivers set.
  4. Finding 1: the injection stops at [VirtIO] ✗ apt install failed: with an empty reason. apt-get -s install qemu-utils on the node shows proxmox-ve among the packages that would be removed.
  5. Install python3-hivex and ntfs-3g by hand, leave libhivex-bin out, run again. Finding 2: the log says VER_BUILD= and SUBDIR=w11/amd64 for a build-20348 guest, then INJECTION_OK.
  6. Install libhivex-bin, run once more. Finding 3: mount the guest's NTFS partition and compare System32/drivers with System32/CatRoot/{F750E6C3-38EE-11D1-85E5-00C04FC295EE}.

Expected behavior

  1. The prerequisite install asks only for packages a Proxmox node can accept, and a failed install says why.
  2. The version probe's own tool is installed with the others — or its absence is reported, instead of silently selecting a default driver variant and reporting success.
  3. Catalogues go to the catalogue store.

Concretely:

  • Drop qemu-utils from the install list and qemu-nbd from the probe. qemu-nbd is needed for file-based storages only, and the script already reports it missing in exactly that branch (v2p.py:2256).
  • Add libhivex-bin to the install list and command -v hivexsh to the probe.
  • CAT_DEST="$WIN_MNT/$WDIR/System32/CatRoot/{F750E6C3-38EE-11D1-85E5-00C04FC295EE}", created with mkdir -p alongside INF_DEST, and the .cat copy pointed at it.

Measured with the fix in place

Same node, same guest, same ISO:

before after
packages requested from apt python3-hivex ntfs-3g qemu-utils python3-hivex ntfs-3g libhivex-bin
packages apt would remove pve-qemu-kvm, proxmox-ve none
VER_BUILD / SUBDIR (empty) / w11/amd64 20348 / 2k22/amd64
catalogues in the catalogue store 0 of 6 6 of 6

All three are implemented and tested on our side, each with unit tests that fail if the behaviour is lost. Happy to open a PR against Testing with just those three changes; say the word if you would rather shape it differently.

One thing worth knowing that is not the subject of this report: the injection runs apt-get install on a hypervisor at all. That is upstream behaviour and every customer node gets it; an operator would want to know before the first migration rather than from the log afterwards.

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, stock install
  • Guest: Windows Server 2022 Standard, build 20348, Generation 1 / seabios / pc
  • 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

Finding 1 — the whole injection log for the step:

[VirtIO] Installing python3-hivex / ntfs-3g / qemu-utils (one-time)...
[VirtIO] ✗ apt install failed:

Finding 2 — same disk, without and with libhivex-bin:

WDIR=Windows
VER_NAME=
VER_BUILD=
SUBDIR_PRIMARY=w11/amd64
SUBDIR=w11/amd64
COPIED vioscsi (/tmp/v2p-virtio-XXXXXX/iso/vioscsi/w11/amd64)
INJECTION_OK
WDIR=Windows
VER_NAME=Windows Server 2022 Standard
VER_BUILD=20348
SUBDIR_PRIMARY=2k22/amd64
SUBDIR=2k22/amd64
COPIED vioscsi (/tmp/v2p-virtio-XXXXXX/iso/vioscsi/2k22/amd64)
INJECTION_OK

Screenshots

Not applicable — everything above is node-side output.

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

P.S.: I'm really sorry that I've published three issues in a row. I have three more in the works, but I'm going to hold off on them for now so you don't get overwhelmed.

Frisch12 avatar Sep 15 '26 08:09 Frisch12

All three confirmed and fixed on Testing (78b0618). The qemu-utils one is the embarrassing one — #520 rewrote the qemu-img preflight specifically to tell people not to run that command on PVE, and the same file goes and runs it 1700 lines further down. apt output is tailed at 25 lines now so the hook's reason actually reaches the log.

One deliberate deviation from your proposal: I did not put hivexsh into the probe that gates the injection. It only feeds the version lookup, the script has a fallback, and on a Windows 11 guest that fallback is the correct variant — so gating on it would turn a migration that works on an air-gapped node into one that fails. It's a separate soft check instead: try to install libhivex-bin, and if it's still missing the script prints NO_HIVEXSH and says outright that the variant is a guess. The rest is as you described, qemu-nbd out of the shared probe, .cat into System32\CatRoot\{F750E6C3-…}.

And no need to apologise for three in a row — three reproducible bugs with the measurements attached is the good kind of burst. Send the DriverDatabase one whenever you like, that's the half that actually makes the guest boot.

Marcus

mkellermann97 avatar Sep 15 '26 10:09 mkellermann97

Fixed in 1.2.0, along with three other injection messages that were telling operators something that hadn't happened. The apt step no longer asks a Proxmox node for a package it doesn't carry.

Marcus

mkellermann97 avatar Sep 21 '26 07:09 mkellermann97