Find VM's with lock

May 20, 2019
2
0
21
51
Netherlands
We're backing up VM's to a NFS device over an IPSEC tunnel. Sometimes the tunnel disappaers for a short time and the backup hangs (which is understandable).
But; next day some VM's cannot be backupped since they 're locked.
Is it possible to find all locked VM's using the API or the "qm status" command ?
 
You need "jq" (apt install jq) for this.

Code:
pvesh get /nodes/$(hostname)/qemu --output-format=json | jq -cr '.[] | select(.["lock"]) | .["vmid"]'
This will return the ID of locked VMs