if ($param->{$opt} eq '1') {
$param->{$opt} = PVE::QemuServer::generate_uuid();
}
+ } elsif ($opt eq 'hookscript') {
+ eval { PVE::GuestHelpers::check_hookscript($param->{$opt}, $storecfg); };
+ raise_param_exc({ $opt => $@ }) if $@;
}
}
use PVE::RPCEnvironment;
use PVE::Exception qw(raise_param_exc);
use PVE::Network;
+use PVE::GuestHelpers;
use PVE::QemuServer;
use PVE::QemuServer::ImportDisk;
use PVE::QemuServer::OVF;
# vm was shutdown from inside the guest or crashed, doing api cleanup
PVE::QemuServer::vm_stop_cleanup($storecfg, $vmid, $conf, 0, 0);
}
+ PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'post-stop');
});
warn "Finished cleanup for $vmid\n";
use PVE::QemuConfig;
use PVE::QMPClient;
use PVE::RPCEnvironment;
+use PVE::GuestHelpers;
use PVE::QemuServer::PCI qw(print_pci_addr print_pcie_addr);
use PVE::QemuServer::Memory;
use PVE::QemuServer::USB qw(parse_usb_device);
default => "1 (autogenerated)",
optional => 1,
},
+ hookscript => {
+ type => 'string',
+ format => 'pve-volume-id',
+ optional => 1,
+ description => "Script that will be executed during various steps in the vms lifetime.",
+ },
};
my $confdesc_cloudinit = {
'description' => 1,
'protection' => 1,
'vmstatestorage' => 1,
+ 'hookscript' => 1,
};
# hotplug changes in [PENDING]
}
}
+ PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'pre-start', 1);
+
my ($cmd, $vollist, $spice_port) = config_to_command($storecfg, $vmid, $conf, $defaults, $forcemachine);
my $migrate_port = 0;
property => "guest-stats-polling-interval",
value => 2) if (!defined($conf->{balloon}) || $conf->{balloon});
+ PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'post-start');
});
}
my $opts = PVE::JSONSchema::pve_parse_startup_order($conf->{startup});
$timeout = $opts->{down} if $opts->{down};
}
+ PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'pre-stop');
}
$timeout = 60 if !defined($timeout);