Guest hookscripts post-stop doesn't finish if shutdown called within VM

rumble06

New Member
Jul 12, 2019
14
1
1
24
Guest hookscript is only firing 'post-stop'. The rest of them ('pre-stop', 'pre-start', 'post-start') never fires, even if the commands are from the UI panel. Neither post-start fires, which i was supposed to fire when the machine is on. Checked that by printing the args and checking daemon.log, only the post-stop event is printed.

Edit: It seems that they are printed inside the task history of that VM. However, I don't seem to be able to create a file inside a guest hookscript, is there any way to communicate between phases? Example, I want to save something on the pre-stop and work with it on the post-stop.

Edit 2: After some more debugging, it seems I am able to create/delete the file successfully, however where it fails it is when calling the post-stop if the vm shutdown from inside (pressing the windows power off button within the VM).
This is the log of a shutdown from the proxmox panel:
Code:
Jul 14 23:46:53 proxmox qmeventd[1170]: Starting cleanup for 100
Jul 14 23:46:53 proxmox qmeventd[1170]: trying to acquire lock...
Jul 14 23:46:55 proxmox qmeventd[1170]:  OK
Jul 14 23:46:55 proxmox qmeventd[1170]: GUEST HOOK: 100 post-stop
Jul 14 23:46:55 proxmox qmeventd[1170]: GUEST HOOK -> post-stop -> File is existent!Finished cleanup for 100

And this is the log of a shutdown from inside the VM itself:
Code:
Jul 14 23:51:18 proxmox qmeventd[1170]: Starting cleanup for 100
Jul 14 23:51:18 proxmox qmeventd[1170]: vm still running

It doesn't finishes the cleanup as it says "vm still running" even tho the VM actually is shutdown
 
Last edited:
what is your pveversion -v and the vm config? i cannot see that behaviour here...
 
what is your pveversion -v and the vm config? i cannot see that behaviour here...

Code:
root@proxmox:~# pveversion -v
proxmox-ve: 5.4-1 (running kernel: 4.15.18-12-pve)
pve-manager: 5.4-3 (running version: 5.4-3/0a6eaa62)
pve-kernel-4.15: 5.3-3
pve-kernel-4.15.18-12-pve: 4.15.18-35
corosync: 2.4.4-pve1
criu: 2.11.1-1~bpo90
glusterfs-client: 3.8.8-1
ksm-control-daemon: 1.2-2
libjs-extjs: 6.0.1-2
libpve-access-control: 5.1-8
libpve-apiclient-perl: 2.0-5
libpve-common-perl: 5.0-50
libpve-guest-common-perl: 2.0-20
libpve-http-server-perl: 2.0-13
libpve-storage-perl: 5.0-41
libqb0: 1.0.3-1~bpo9
lvm2: 2.02.168-pve6
lxc-pve: 3.1.0-3
lxcfs: 3.0.3-pve1
novnc-pve: 1.0.0-3
proxmox-widget-toolkit: 1.0-25
pve-cluster: 5.0-36
pve-container: 2.0-37
pve-docs: 5.4-2
pve-edk2-firmware: 1.20190312-1
pve-firewall: 3.0-19
pve-firmware: 2.0-6
pve-ha-manager: 2.0-9
pve-i18n: 1.1-4
pve-libspice-server1: 0.14.1-2
pve-qemu-kvm: 2.12.1-3
pve-xtermjs: 3.12.0-1
qemu-server: 5.0-50
smartmontools: 6.5+svn4324-1
spiceterm: 3.0-5
vncterm: 1.5-3
zfsutils-linux: 0.7.13-pve1~bpo2

And the VM config:

Code:
agent: 1
balloon: 2048
bios: ovmf
boot: cdn
bootdisk: scsi0
cores: 12
cpu: host,flags=+pcid
efidisk0: ssd:vm-100-disk-1,size=128K
hookscript: local:snippets/shutdown.pl
hostpci0: 07:00,pcie=1
ide2: local:iso/virtio-win.iso,media=cdrom,size=309208K
machine: q35
memory: 14336
name: Windows10Main
net0: virtio=B6:50:82:E3:7D:F1,bridge=vmbr0,firewall=1
numa: 1
onboot: 1
ostype: win10
scsi0: ssd:vm-100-disk-0,iothread=1,replicate=0,size=465G,ssd=1
scsi1: hdd1:vm-100-disk-0,iothread=1,replicate=0,size=900G
scsihw: virtio-scsi-single
smbios1: uuid=da66315e-4040-4135-b6ad-3db9f46d38ce
sockets: 1
usb0: host=1-2
usb1: host=1-4
usb2: host=1-5
usb3: host=1-1
usb4: host=1f75:0917,usb3=1
vga: none
vmgenid: a69c7843-1478-4106-84c3-ac238387c83b


Also not sure if related, but it seems that there is kvm warning on the VM boot, even tho the VM boots and works without any issue (I can run any software and play any game that I was able to play without virtualization):

Code:
()
GUEST HOOK: 100 pre-start
kvm: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
kvm: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
kvm: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
kvm: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
kvm: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
kvm: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
kvm: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
kvm: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
kvm: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
kvm: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
kvm: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
kvm: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
GUEST HOOK: 100 post-start
GUEST HOOK -> post-start executedTASK OK

CPU: Ryzen 5 2600

Edit: seems like after adding "args: -cpu 'host,+kvm_pv_unhalt,+kvm_pv_eoi,hv_vendor_id=NV43FIX,kvm=off'" to the VM configuration the error is gone:
Code:
GUEST HOOK: 100 pre-start
GUEST HOOK: 100 post-start
GUEST HOOK -> post-start executedTASK OK
However the start process appears as "Status: stopped: unexpected status" even tho the VM boots fine. The hookscript exists with the code of 0 ("exit(0);") so it shouldn't be that. Not sure if related to the post-stop thing, but I thought it's worth mentioning

Edit2: Seems like "unexpected status" from the VM start was because the printed message from the hookscript wasn't ending with "\n" and apparently the status is returned as successfull only if "TASK ON" is on it's own line. In conclusion this does not have anything to do with the post-stop problem I'm having, it is still not firing because "the vm is running"

As the above warning wasn't affecting the post-stop thing, I removed those args from the conf as with the args the cpu performance of the VM is reduced dramatically (for example, playing a game results in stutering inside the game). Without the args, even if the start event complains with warnings it works without any performance-loss because of the virtualization.
 
Last edited:
Hello,

have you found a solution to the problem? I'm struggeling, too, with the 'no post-stop' event, when the VM was shutdown from itself.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!