Automatically force stop a VM on shutdown

nintendoeats

Member
Aug 10, 2024
2
0
6
Hello,

I have a VM that does not, and never will, support ACPI shutdown. It's an image from an embedded device, it is designed to be simply turned off. Unfortunately this VM prevents me from shutting down my hypervisor normally; I have to force stop the VM first, then shut down the system or else it will hang.

I tried setting a shutdown timeout of 5 seconds, and it certainly reports the timeout but it doesn't...do anything about it. The VM carries on regardless.

Is there a sensible way to specify that this VM needs to be force stopped on system shutdown?

Thanks!
 
This hookscript appear to do the trick of stopping the VM when you want to shut down the VM:
Bash:
#!/bin/bash
echo "$0 $*"
if [ "$2" = 'pre-stop' ]
then
    nohup /usr/sbin/qm stop "$1" &>/dev/null &
fi
I tested it on a VM (with a Shutdown timeout of 1) that was waiting in the boot menu and therefore not responding to ACPI.
 
Last edited:
This hookscript appear to do the trick of stopping the VM when you want to shut down the VM:
Bash:
#!/bin/bash
echo "$0 $*"
if [ "$2" = 'pre-stop' ]
then
    nohup /usr/sbin/qm stop "$1" &>/dev/null &
fi
I tested it on a VM (with a Shutdown timeout of 1) that was waiting in the boot menu and therefore not responding to ACPI.

Thanks, yeah that seems about right. I haven't done a system shutdown, but the VM does stop now when I request a shutdown. Hookscripts seem like a handy tool to add to my kit.