From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id B4D3C1FF09F for ; Thu, 03 Sep 2026 10:54:07 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 876D621599; Thu, 03 Sep 2026 10:54:07 +0200 (CEST) Content-Type: text/plain; charset=UTF-8 Date: Thu, 03 Sep 2026 10:54:03 +0200 Message-Id: From: "Jakob Klocker" To: "Dominik Csapak" , Subject: Re: [PATCH docs/guest-common/qemu-server v4 0/7] add new pci passthrough specific hookscript phase Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: aerc 0.20.0 References: <20260825135502.3971930-1-d.csapak@proxmox.com> In-Reply-To: <20260825135502.3971930-1-d.csapak@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1788425640950 X-SPAM-LEVEL: Spam detection results: 0 AWL 1.650 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 2ILPRG5OZUMH44ZU2C66YBHXLTJ5OST7 X-Message-ID-Hash: 2ILPRG5OZUMH44ZU2C66YBHXLTJ5OST7 X-MailFrom: j.klocker@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Tested this on an NVIDIA RTX A5000 (SR-IOV vGPU) plus plain PCI passthrough. What I tested: - Confirmed the state of the VM and the PCIe devices in the=20 `post-pci-prepare` hook: - VM status is `stopped` with no PID, QEMU hasn't launched yet - The device is prepared at this point: for the nvidia SR-IOV vGPU, `current_vgpu_type` on the VF goes from `0` (pre-start) to `2170` (post-pci-prepare); for plain passthrough the device is bound to `vfio-pci`. - `PVE_HOOK_ID` and `PVE_HOOK_PCIID` correctly identify the config slot and the specific device. - The hook fires once per prepared PCI function. - Successfully wrote `frame_rate_limiter=3D0` via the `post-pci-prepare` hook (verified via read-back). Note: the value needs a trailing newline -- without it, it's written truncated and the VF ends up in a state where QEMU fails to open it (device start fails with an I/O error). - Checked that devices are cleaned up via `cleanup_pci_devices` if the hookscript dies. Backwards-compatibility concern (thanks to Elias): the `post-pci-prepare` hook is called with `stop_on_error=3D1`, and the example script dies on unknown phases (`else { die }`). Existing hookscripts modeled on the old example will therefore abort VM start as soon as they encounter the new phase. Might be worth either calling this phase non-fatally, or noting it in the docs/example. The nits mentioned on the patches are of course none blocking, so once the backwards-compatibility concern is addressed/acknowleded consider this: Reviewed-by: Jakob Klocker Tested-by: Jakob Klocker On Tue Aug 25, 2026 at 3:54 PM CEST, Dominik Csapak wrote: > this series adds a new phase to the guest hookscript that is called for e= ach > passed throug pci device after it's prepared, but before the qemu process= is > started. > > See the last qemu-server commit for why that is interesting. > > changes from v4: > * rebase on current master > * fix `local %ENV` clearing the whole environment instead of > just shadowing it, so the hookscript keeps the inherited environment > * split the uuid handling out of the refactoring commit > * call the hookscript once for both the mdev and the plain passthrough > case instead of duplicating the call in both branches > * add missing `use PVE::GuestHelpers;` > * move the new phase before 'post-start' to match the actual call > order, document that PVE_HOOK_MDEV_UUID is only set for mdevs, and > mention what the phase is useful for > * fix typos > > changes from v3: > * split unrelated logic/refactoring changes out to their own patches > * fix typos > > changes from v2: > * rebase on current master > * prefix hook script env variables with 'PVE_HOOK_' > > > pve-guest-common: > > Dominik Csapak (1): > helpers: exec hookscript: add optional parameters > > src/PVE/GuestHelpers.pm | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > > qemu-server: > > Dominik Csapak (5): > pci: mdev preparation: always generate local uuid first > pci: nvidia vgpu: correct wrong comment about uuid > pci: factor 'prepare_pci_devices' out to PVE::QemuServer::PCI module > pci: preparation: mdev: only generate uuid once > pci: call hookscript for each prepared pci device > > src/PVE/QemuServer.pm | 45 ++++++--------------------------- > src/PVE/QemuServer/PCI.pm | 52 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 60 insertions(+), 37 deletions(-) > > > pve-docs: > > Dominik Csapak (1): > examples: add new hookscript phase to example hookscript > > examples/guest-example-hookscript.pl | 29 ++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > > > Summary over all repositories: > 4 files changed, 100 insertions(+), 38 deletions(-)