From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH docs v3 1/1] examples: add new hookscript phase to example hookscript
Date: Fri, 27 Feb 2026 13:06:54 +0100 [thread overview]
Message-ID: <20260227120728.2152303-5-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260227120728.2152303-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>
---
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..da14fd1 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{PVE_HOOK_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{PVE_HOOK_PCIID};
+
+ # the uuid of the mediated device if it was one,
+ # e.g. '00000001-0000-0000-0000-000000008006'
+ my $mdev_uuid = $ENV{PVE_HOOK_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
prev parent reply other threads:[~2026-02-27 12:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 12:06 [PATCH docs/guest-common/qemu-server v3 0/4] add new pci passthrough specific hookscript phase Dominik Csapak
2026-02-27 12:06 ` [PATCH guest-common v3 1/1] helpers: exec hookscript: add optional parameters Dominik Csapak
2026-02-27 12:06 ` [PATCH qemu-server v3 1/2] pci: factor 'prepare_pci_devices' out to PVE::QemuServer::PCI module Dominik Csapak
2026-02-27 12:06 ` [PATCH qemu-server v3 2/2] pci: call hookscript for each prepared pci device Dominik Csapak
2026-02-27 12:06 ` 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=20260227120728.2152303-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.