[pve-devel] [PATCH guest-common 1/1] helpers: exec hookscript: add optional parameters
Dominik Csapak
d.csapak at proxmox.com
Wed Jan 14 16:50:30 CET 2026
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.
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
src/PVE/GuestHelpers.pm | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/PVE/GuestHelpers.pm b/src/PVE/GuestHelpers.pm
index f8d112b..1da7619 100644
--- a/src/PVE/GuestHelpers.pm
+++ b/src/PVE/GuestHelpers.pm
@@ -115,15 +115,19 @@ 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 $@;
- PVE::Tools::run_command([$hookscript, $vmid, $phase]);
+ my $cmd = [$hookscript, $vmid, $phase];
+ push $cmd->@*, $params->@*;
+ PVE::Tools::run_command($cmd);
};
if (my $err = $@) {
my $errmsg = "hookscript error for $vmid on $phase: $err\n";
--
2.47.3
More information about the pve-devel
mailing list