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

[Bug] SMBIOS autoconfig daemon re-stamps running VMs every poll cycle — get_current_smbios() is not [PENDING]-section aware

Open daglimmer opened this issue 2 months ago • 1 comments

Describe the bug

The SMBIOS auto-configurator daemon (deployed from SMBIOS_SCRIPT_TEMPLATE in pegaprox/api/nodes.py via the smbios-autoconfig endpoint) re-writes smbios1 on running VMs on every poll cycle (30s default), generating a new serial each time. On a 7-node deployment this accumulated ~1.5M spurious qm set writes in ~30 days (worst node: 873k writes and a 121 MB daemon log), with serial churn on every running VM, constant pmxcfs write pressure, config-version noise for backup jobs, and unbounded log growth.

Steps to Reproduce

  1. Enable the SMBIOS auto-configurator on a node with at least one running VM.
  2. Watch /var/log/pegaprox-smbios.log (or the VM conf's [PENDING] section).
  3. Observe a new Set SMBIOS for VM <vmid> | Serial: PVE... entry every poll cycle, with a different serial each time — indefinitely. After the next VM start applies the pending value, the loop restarts immediately.

Log excerpt (two consecutive cycles, same running VM, 3 seconds apart):

[2026-08-22 11:24:54] Set SMBIOS for VM <vmid> | Serial: PVE2608221124521215
[2026-08-22 11:24:57] Set SMBIOS for VM <vmid> | Serial: PVE2608221124545734

Expected behavior

The daemon stamps a VM once; on subsequent cycles get_current_smbios() returns the daemon's own previous stamp and the daemon logs already has SMBIOS configuration, issuing no further writes while the VM keeps running.

Root cause

qm set on a running VM does not change the active config — it records the change in the [PENDING] section of /etc/pve/qemu-server/<vmid>.conf, applied at the next VM start. get_current_smbios() scans the conf and returns the first smbios1: line found:

with open(conf_path, 'r') as f:
    for line in f:
        if line.startswith('smbios1:'):
            return line.split(':', 1)[1].strip()

After the daemon stamps a running VM, the stamp lives only in [PENDING], invisible to the daemon → needs_smbios_update() always True → new qm set every cycle → loop.

Proposed direction (happy to adjust to maintainer preference): make get_current_smbios() section-aware — a pending smbios1: wins over the main-section value, and smbios1: inside other bracketed sections (snapshot sections keep a stale copy of old config) is ignored. One function, one file. We have a tested patch with fleet verification ready to PR once the direction is confirmed — after deploying the fixed daemon template the re-stamp loop stopped immediately on all 7 nodes (every cycle logs already has SMBIOS configuration, zero Set SMBIOS entries across multiple poll cycles).

Environment

  • PegaProx Version: 1.1.1 (deployed); function unchanged in current main / v1.2.0 source (pegaprox/api/nodes.py, get_current_smbios at line 1441)
  • Installation Method: Manual (git clone)
  • OS: Debian 12
  • Behind Reverse Proxy? irrelevant (daemon-side bug)
  • UI? N/A

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 🪄

daglimmer avatar Sep 23 '26 07:09 daglimmer

Reproduced. qm set on a running guest lands in [PENDING] and get_current_smbios() only ever read the main section, so the daemon can't see its own stamp and re-writes it every cycle — your two log lines 3s apart are exactly that.

Also checked the section name against PVE's own source rather than guessing: QemuServer.pm writes $raw .= "\n[PENDING]\n", so matching on the literal is fine. The function is unchanged in 1.1.1 and 1.2.0, so both are affected.

Thanks for digging into the root cause instead of just reporting the symptom, that saved us the whole investigation.

Marcus

mkellermann97 avatar Sep 23 '26 07:09 mkellermann97