From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH docs v2 1/1] examples: add new hookscript phase to example hookscript
Date: Fri, 23 Jan 2026 14:25:50 +0100 [thread overview]
Message-ID: <20260123132611.974310-5-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260123132611.974310-1-d.csapak@proxmox.com>
qemu-server has a new phase 'post-pci-prepare' that is called for vms
with pci passthrough for each device prepared.
add that to the example hookscript and explain when it's called and it's
parameters with a comment.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
changes from v1:
* adapt to the changes from positional parameters to environment variables
examples/guest-example-hookscript.pl | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/examples/guest-example-hookscript.pl b/examples/guest-example-hookscript.pl
index 1cce2e3..a5a50d5 100755
--- a/examples/guest-example-hookscript.pl
+++ b/examples/guest-example-hookscript.pl
@@ -38,6 +38,31 @@ if ($phase eq 'pre-start') {
print "$vmid started successfully.\n";
+} elsif ($phase eq 'post-pci-prepare') {
+
+ # Only called for virtual machines, not containers.
+ #
+ # This phase will be called for each pci device that is passed through,
+ # after it was prepared by the PVE stack. In other words when either
+ # * the mdev/vGPU was created
+ # * the driver was changed to vfio-pci and the device was reset
+ #
+ # This phase has 3 additional parameters given via the environment
+
+ # the id from the config, e.g. 'hostpci0'
+ my $hostpci_x = $ENV{ID};
+
+ # the pciid of the passed through device or the underlying device in case of an mdev/vGPU
+ # e.g. '0000:01:00.0'
+ my $pciid = $ENV{PCIID};
+
+ # the uuid of the mediated device if it was one,
+ # e.g. '00000001-0000-0000-0000-000000008006'
+ my $mdev_uuid = $ENV{MDEV_UUID};
+
+ print "Prepared PCI device for $hostpci_x with pciid: $pciid.\n";
+ print "It is a mediated device with UUID: $mdev_uuid\n" if $mdev_uuid;
+
} elsif ($phase eq 'pre-stop') {
# Third phase 'pre-stop' will be executed before stopping the guest
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
prev parent reply other threads:[~2026-01-23 13:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 13:25 [pve-devel] [PATCH docs/guest-common/qemu-server v2 0/4] add new pci passthrough specific hookscript phase Dominik Csapak
2026-01-23 13:25 ` [pve-devel] [PATCH guest-common v2 1/1] helpers: exec hookscript: add optional parameters Dominik Csapak
2026-01-23 13:25 ` [pve-devel] [PATCH qemu-server v2 1/2] pci: factor 'prepare_pci_devices' out to PVE::QemuServer::PCI module Dominik Csapak
2026-01-23 13:25 ` [pve-devel] [PATCH qemu-server v2 2/2] pci: call hookscript for each prepared pci device Dominik Csapak
2026-01-23 13:25 ` Dominik Csapak [this message]
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=20260123132611.974310-5-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.