From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu-server v5 7/9] pci: call hookscript for each prepared pci device
Date: Wed, 23 Sep 2026 09:05:00 +0200 [thread overview]
Message-ID: <20260923070522.434715-8-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260923070522.434715-1-d.csapak@proxmox.com>
There are situations where a user might want to do extra things
for a passed through PCI device after it has been prepared/created (e.g.
in case of vGPU/mdev) but before the actual QEMU process is started.
Two examples are (both are used with NVIDIA vGPUs):
* setting 'vgpu_params' such as removing the frame-rate-limiter
* setting the gpu_instance_id for MIG devices
So instead of creating (nvidia-specific) interfaces for these, give a
user the ability to do it themselves via the hookscript as a first step.
Call it for each prepared device, so that we can give the hookscript the
'hostpciX' id, and the used uuid (in case of mdevs) or the pci id (in
case of regular or modern vGPU passthrough).
A failing hookscript aborts, and blocks the VM start.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Elias Huhsovitz <e.huhsovitz@proxmox.com>
Tested-by: Elias Huhsovitz <e.huhsovitz@proxmox.com>
Reviewed-by: Jakob Klocker <j.klocker@proxmox.com>
Tested-by: Jakob Klocker <j.klocker@proxmox.com>
---
src/PVE/QemuServer/PCI.pm | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/PVE/QemuServer/PCI.pm b/src/PVE/QemuServer/PCI.pm
index 7bfe1791..8a7328b0 100644
--- a/src/PVE/QemuServer/PCI.pm
+++ b/src/PVE/QemuServer/PCI.pm
@@ -5,6 +5,7 @@ use strict;
use IO::File;
+use PVE::GuestHelpers;
use PVE::JSONSchema;
use PVE::Mapping::PCI;
use PVE::SysFSTools;
@@ -738,10 +739,17 @@ sub prepare_pci_devices {
if ($pci_device->{mdev} || $pci_device->{nvidia}) {
warn $@ if $@;
$chosen_mdev = $info;
- last if $chosen_mdev; # if successful, we're done
} else {
die $@ if $@;
}
+
+ next if !defined($info);
+
+ my $params = { id => $id, pciid => $info->{name} };
+ $params->{mdev_uuid} = $info->{uuid} if defined($info->{uuid});
+ PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'post-pci-prepare', 1, $params);
+
+ last if defined($chosen_mdev);
}
next if !$pci_device->{mdev} && !$pci_device->{nvidia};
--
2.47.3
next prev parent reply other threads:[~2026-09-23 7:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 7:04 [PATCH docs/guest-common/qemu-server v5 0/9] add new pci passthrough specific hookscript phase Dominik Csapak
2026-09-23 7:04 ` [PATCH guest-common v5 1/9] helpers: exec hookscript: add optional parameters Dominik Csapak
2026-09-23 7:04 ` [PATCH qemu-server v5 2/9] pci: mdev preparation: always generate local uuid first Dominik Csapak
2026-09-23 7:04 ` [PATCH qemu-server v5 3/9] pci: nvidia vgpu: correct wrong comment about uuid Dominik Csapak
2026-09-23 7:04 ` [PATCH qemu-server v5 4/9] pci: factor 'prepare_pci_devices' out to PVE::QemuServer::PCI module Dominik Csapak
2026-09-23 7:04 ` [PATCH qemu-server v5 5/9] code cleanup: pci: rename 'd' variable to 'pci_device' Dominik Csapak
2026-09-23 7:04 ` [PATCH qemu-server v5 6/9] pci: preparation: mdev: only generate uuid once Dominik Csapak
2026-09-23 7:05 ` Dominik Csapak [this message]
2026-09-23 7:05 ` [PATCH docs v5 8/9] examples: add new hookscript phase to example hookscript Dominik Csapak
2026-09-23 7:05 ` [PATCH docs v5 9/9] examples: downgrade 'die' in example hookscript to 'warn' Dominik Csapak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260923070522.434715-8-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.