hookscript execution order during migration

tawh

Active Member
Mar 26, 2019
23
0
41
35
I have written a hookscript for monitoring the network change after starting or stopping of some VM. It works for actual startup and shutdown of VM on a PVE.
However, when I do the migration between to PVEs, only the target PVE calls the hookscript with the pre-start and post-start parameters PRIOR to the start of migration, but on the source PVE side, It doesn't call the hookscript.

I am curious why there is no pre-stop or post-stop calls to the hookscript on the source PVE side?

proxmox-ve: 7.2-1 (running kernel: 5.15.35-1-pve)
pve-manager: 7.2-3 (running version: 7.2-3/c743d6c1)
pve-kernel-5.15: 7.2-3
pve-kernel-helper: 7.2-3
pve-kernel-5.4: 6.4-15
pve-kernel-5.15.35-1-pve: 5.15.35-2
pve-kernel-5.4.174-2-pve: 5.4.174-2
pve-kernel-5.4.34-1-pve: 5.4.34-2
ceph: 15.2.16-pve1
ceph-fuse: 15.2.16-pve1
corosync: 3.1.5-pve2
criu: 3.15-1+pve-1
glusterfs-client: 9.2-1
ifupdown: 0.8.36+pve1
ksm-control-daemon: 1.4-1
libjs-extjs: 7.0.0-1
libknet1: 1.22-pve2
libproxmox-acme-perl: 1.4.2
libproxmox-backup-qemu0: 1.2.0-1
libpve-access-control: 7.1-8
libpve-apiclient-perl: 3.2-1
libpve-common-perl: 7.1-6
libpve-guest-common-perl: 4.1-2
libpve-http-server-perl: 4.1-1
libpve-storage-perl: 7.2-2
libqb0: 1.0.5-1
libspice-server1: 0.14.3-2.1
lvm2: 2.03.11-2.1
lxc-pve: 4.0.12-1
lxcfs: 4.0.12-pve1
novnc-pve: 1.3.0-3
proxmox-backup-client: 2.1.8-1
proxmox-backup-file-restore: 2.1.8-1
proxmox-mini-journalreader: 1.3-1
proxmox-widget-toolkit: 3.4-10
pve-cluster: 7.2-1
pve-container: 4.2-1
pve-docs: 7.2-2
pve-edk2-firmware: 3.20210831-2
pve-firewall: 4.2-5
pve-firmware: 3.4-2
pve-ha-manager: 3.3-4
pve-i18n: 2.7-1
pve-qemu-kvm: 6.2.0-5
pve-xtermjs: 4.16.0-1
qemu-server: 7.2-2
smartmontools: 7.2-pve3
spiceterm: 3.2-2
swtpm: 0.7.1~bpo11+1
vncterm: 1.7-1
zfsutils-linux: 2.1.4-pve1
 
Hello, is there anyone have experience on using hookscript for migration?
 
Hi,
unfortunately, there are no such hooks yet. There is a feature request for it, but we haven't come around to implementing them yet. Comment 2 explains why the stop hooks don't trigger with the current implementation.
 
the pre and post-stop hook points are skipped on the source side (mainly because at that point, the config file is not there anymore, and existing hook scripts might rely on only being called with the config in place). IIRC the hookscript on the target node does get the info that the start happens as part of a migration and where the migration is coming from (PVE_MIGRATED_FROM environment variable), so you can detect that, connect back to the indicated source node and either call the hookscript yourself or whatever action you want to take directly. but keep in mind that both pre-start and post-start in a migration happen before the source VM is stopped, so depending on what you want to do, you might want to wait for the source VM to exit.

see https://bugzilla.proxmox.com/show_bug.cgi?id=1996 for some more discussion about potential extensions.
 
Dear
the pre and post-stop hook points are skipped on the source side (mainly because at that point, the config file is not there anymore, and existing hook scripts might rely on only being called with the config in place). IIRC the hookscript on the target node does get the info that the start happens as part of a migration and where the migration is coming from (PVE_MIGRATED_FROM environment variable), so you can detect that, connect back to the indicated source node and either call the hookscript yourself or whatever action you want to take directly. but keep in mind that both pre-start and post-start in a migration happen before the source VM is stopped, so depending on what you want to do, you might want to wait for the source VM to exit.

see https://bugzilla.proxmox.com/show_bug.cgi?id=1996 for some more discussion about potential extensions.
Thanks for your insight.