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 B7F031FF0B7 for ; Tue, 25 Aug 2026 15:55:58 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 44213216D6; Tue, 25 Aug 2026 15:55:09 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Subject: [PATCH docs v4 7/7] examples: add new hookscript phase to example hookscript Date: Tue, 25 Aug 2026 15:54:52 +0200 Message-ID: <20260825135502.3971930-8-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260825135502.3971930-1-d.csapak@proxmox.com> References: <20260825135502.3971930-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.716 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: NGMIZZ2GLLLTUYXG3GRNZZFGHSSVYTFI X-Message-ID-Hash: NGMIZZ2GLLLTUYXG3GRNZZFGHSSVYTFI X-MailFrom: d.csapak@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: 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 its parameters with a comment. Signed-off-by: Dominik Csapak --- examples/guest-example-hookscript.pl | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/examples/guest-example-hookscript.pl b/examples/guest-example-hookscript.pl index 1cce2e3..02e7e7d 100755 --- a/examples/guest-example-hookscript.pl +++ b/examples/guest-example-hookscript.pl @@ -31,6 +31,35 @@ if ($phase eq 'pre-start') { # print "preparations failed, aborting." # exit(1); +} 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 Proxmox VE 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 can be useful to do additional preparation that the Proxmox VE + # stack does not do, like setting vgpu_params for NVIDIA vGPU. + # + # This phase has 3 additional parameters (one optional) given via the environment: + + # the id from the config, e.g. 'hostpci0' + my $hostpci_id = $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' + # This is not set if the pci device is not an mdev. + my $mdev_uuid = $ENV{PVE_HOOK_MDEV_UUID}; + + print "Prepared PCI device for $hostpci_id with pciid: $pciid.\n"; + print "It is a mediated device with UUID: $mdev_uuid\n" if $mdev_uuid; + } elsif ($phase eq 'post-start') { # Second phase 'post-start' will be executed after the guest -- 2.47.3