From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>,
Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH guest-common v2 1/1] helpers: exec hookscript: add optional parameters
Date: Fri, 13 Feb 2026 12:04:49 +0100 [thread overview]
Message-ID: <1770980615.qmyhx86j1s.astroid@yuna.none> (raw)
In-Reply-To: <5296fd4d-e207-4e0f-9e3f-af5be4e2453a@proxmox.com>
On February 13, 2026 11:52 am, Dominik Csapak wrote:
>
>
> On 2/13/26 11:47 AM, Fabian Grünbichler wrote:
>> On January 23, 2026 2:25 pm, Dominik Csapak wrote:
>>> sometimes we may want to call the hookscript with additional parameters
>>> in some phases, e.g. we want to call it for each pci device that was
>>> prepared before starting with the correct uuid or pci id.
>>>
>>> Add these new parameters to the environment instead of the positional
>>> parameters of the hookscript, since that is more future proof and we get
>>> a key/value pair instead of just the position.
>>>
>>> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
>>> ---
>>> changes from v1:
>>> * use a hash instead of a list for the parameters, and give them to the
>>> hookscript via the environment instead of positional parameters, like
>>> we do for the vzdump hookscript
>>>
>>> src/PVE/GuestHelpers.pm | 10 +++++++++-
>>> 1 file changed, 9 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/src/PVE/GuestHelpers.pm b/src/PVE/GuestHelpers.pm
>>> index f8d112b..b4122e6 100644
>>> --- a/src/PVE/GuestHelpers.pm
>>> +++ b/src/PVE/GuestHelpers.pm
>>> @@ -115,14 +115,22 @@ sub check_hookscript {
>>> }
>>>
>>> sub exec_hookscript {
>>> - my ($conf, $vmid, $phase, $stop_on_error) = @_;
>>> + my ($conf, $vmid, $phase, $stop_on_error, $params) = @_;
>>>
>>> return if !$conf->{hookscript};
>>>
>>> + $params //= {};
>>> +
>>> eval {
>>> my $hookscript = check_hookscript($conf->{hookscript});
>>> die $@ if $@;
>>>
>>> + local %ENV;
>>> +
>>> + for my $key (keys $params->%*) {
>>> + $ENV{ uc($key) } = $params->{$key};
>>
>> this should really have some sort of static prefix, both to avoid
>> clashes, and to allow the hookscript to find all such parameters (e.g.
>> for logging purposes) by filtering all set env variables.
>>
>> PVE_HOOKSCRIPT_PARAM_...
>>
>> or something similar would do the trick?
>
>
> yep make sense, but maybe something a bit shorter?
>
> PVE_PARAM_
>
> PVE_HS_PARAM_
>
> PVE_HS_
>
> ?
yeah, anything short but specific enough to avoid accidents should be
fine. maybe `PVE_HOOK_` ?
next prev parent reply other threads:[~2026-02-13 11:04 UTC|newest]
Thread overview: 9+ 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-02-13 10:47 ` Fabian Grünbichler
2026-02-13 10:52 ` Dominik Csapak
2026-02-13 11:04 ` Fabian Grünbichler [this message]
2026-02-13 11:10 ` 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 ` [pve-devel] [PATCH docs v2 1/1] examples: add new hookscript phase to example hookscript 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=1770980615.qmyhx86j1s.astroid@yuna.none \
--to=f.gruenbichler@proxmox.com \
--cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox