Shutdown VM

taich

Active Member
Aug 15, 2020
117
22
38
66
After fresh installation of a VM where it does not have installed qemu-guest-agent it is mostly not possible to shutdown or stop the vm from outside the VM. What is the recommended action for this situation?

Thanks
 
Last edited:
Did you enable the guest agent in the VM creation wizard, or in the options before starting the VM?
 
In the meantime I created a little bash script <kill-vm>

Bash:
#!/bin/bash
#

if [ $# -lt 1 ] ; then
   echo "Usage: kill-vm <vmid>"
   exit
fi

VMID=${1}

EXIST=`qm list | awk '{print $1}' | grep -c ${VMID}$`
if [ ${EXIST} -eq 1 ]; then
   PID=`ps waux | grep "/usr/bin/kvm" | grep "id ${VMID}" | awk '{print $2}'`
   echo "Kill VMID ${VMID} PID ${PID}"
   kill -9 ${PID}
else
   echo "VMID ${VMID} does not exist or is not runnnig!"
fi
 
Last edited: