[SOLVED] How to promptly kill a VM that will never be able to shutdown?

CRCinAU

Well-Known Member
May 4, 2020
120
36
48
crc.id.au
Hi all,

So I'm running a Cisco virtual appliance in a proxmox VM - and these things are not designed to shut down at all. There's no command to tell it to shutdown, nor is there any way to install an agent or have it use acpi etc.

As such, telling a node to reboot will always hang on this VM until the global timeout timer triggers and forcefully kills it.

Is there a way that I can set a VM specific option that will kill this VM after 5 seconds - while not waiting for the global timer?
 
Yes, see VM Options, Start/Shutdown order.
Ahhhh h- I've seen that a million times and it never occurred to me :)

For the sake of the Google results:
  • Shutdown timeout: Defines the duration in seconds Proxmox VE should wait for the VM to be offline after issuing a shutdown command. By default this value is set to 180, which means that Proxmox VE will issue a shutdown request and wait 180 seconds for the machine to be offline. If the machine is still online after the timeout it will be stopped forcefully.

That in theory should be fine if I set it to like 3 seconds. I'll have a play with it, and if that doesn't fit, I'll go with the hookscript route....
 
Oh, if I changed the shutdown timeout to 3, I get the following error when sending a shutdown:
TASK ERROR: VM quit/powerdown failed
Looks like the hookscript might be the way to go.
 
Last edited:
I don't think the Proxmox GUI automatically switches from Shutdown to Stop. When you shutdown the node, it should go faster.
Yeah, I guess that the key is that I want it to work the same way no matter which way it's called..... so it looks like the hook might be an idea...
 
As such, telling a node to reboot will always hang on this VM until the global timeout timer triggers and forcefully kills it.
I do think this is fixed by setting the shutdown timeout to 1 second (why did you set it to 3?).
Yeah, I guess that the key is that I want it to work the same way no matter which way it's called..... so it looks like the hook might be an idea...
Proxmox does different things unless you use the pre-shutdown hookscript. Does pressing Stop work for the VM (after disabling the ACPI support option)?
 
Did you also disable the ACPI support setting in the VM Options?
I did not - just testing again now.... Doesn't seem to make a difference...
I do think this is fixed by setting the shutdown timeout to 1 second (why did you set it to 3?).
1 or 3 doesn't seem to make a difference - I set it to 3 to give me chance to bring up the logs.... It still just fails though....
Does pressing Stop work for the VM (after disabling the ACPI support option)?
Hitting STOP has always worked, but I always hit Shutdown out of habit.... So I essentially want to make Shutdown do the same as a STOP on this VM :)
 
I did not - just testing again now.... Doesn't seem to make a difference...
I'm surprised. Thank you for testing.
Hitting STOP has always worked, but I always hit Shutdown out of habit.... So I essentially want to make Shutdown do the same as a STOP on this VM :)
Try this hookscript:
Bash:
#!/bin/bash
if [ "$2" == "pre-stop" ]
then
    nohup /usr/sbin/qm stop "$1" &>/dev/null &
fi
EDIT: I hope it does not give a endless loop. I use it with qm destroy to delete VMs on shutdown.
 
Last edited:
  • Like
Reactions: CRCinAU
That saved me a bit of time - thanks... I was just looking at the example figuring out what is what.

It does work, but you still need to set the Shutdown timeout to 1 - otherwise the two tasks will block each other.

Keeping the shutdown timeout to 1, and that script as a hookscript does seem to work well though...

Thanks again.
 
  • Like
Reactions: leesteken

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!