I’ve been running a few VMs on Proxmox, including a Pfsense VM, for over a year without a single issue. This evening, however, I noticed that I wasn’t able to access any local DNS records due to the VM hosting DNS server was not responding.
On checking the Proxmox console, I could see that that VM with ID 102 was definitely not responding. So, I tried to reboot, stop and even reset. None of which worked. Knowing that Proxmox is based on or using KVM, I guess there must be many commands that can be run directly on the Proxmox host itself.
As I found out, Proxmox doesn’t make use of virsh
command, and based on this site [1], we can instead use qm
command (qm - QEMU/KVM Virtual Machine Manager) to stop/start VM etc.
First thing I attempted was to stop the VM from the command line after logging into the Proxmox host. I already knew the my VM ID is 102, however, you can list
the VMID from the /etc/pve/.vmlist
file.
root@pve:~# cat /etc/pve/.vmlist
{
"version": 1,
"ids": {
"100": { "node": "pve", "type": "qemu", "version": 3 },
"102": { "node": "pve", "type": "qemu", "version": 5 },
"104": { "node": "pve", "type": "qemu", "version": 2 },
"101": { "node": "pve", "type": "qemu", "version": 1 },
"103": { "node": "pve", "type": "qemu", "version": 4 }}
}
To stop the VM with ID 102, I executed the command:
root@pve:~# qm stop 102
trying to acquire lock...
can't lock file '/var/lock/qemu-server/lock-102.conf' - got timeout
From that above error message, my next sensible attempt was to unlock this VM.
root@pve:~# qm unlock 102
trying to acquire lock...
can't lock file '/var/lock/qemu-server/lock-102.conf' - got timeout
Again, it didn’t work. Based on [1], “The timeout error occurs when the virtual machine is locked or the process is still running in the background.”
So what to do? I didn’t have much choice but to kill the kvm process responsible for running this VM with ID 102, but first I needed to find that kvm process ID:
root@pve:~# ps aux | grep "/usr/bin/kvm -id 102"
root 3226657 9.4 39.2 8867996 6372952 ? SLl Feb11 9944:45 /usr/bin/kvm -id 102 -name ...<SNIP>...
root 3637798 0.0 0.0 6376 708 pts/0 S+ 20:56 0:00 grep /usr/bin/kvm -id 102
Now that I had the ID of kvm process as 3226657, to kill that process, just run:
root@pve:~# kill -9 3226657
Just like that, my VM was back and running again.
Reference: