Checking for VM's with Lock

greavette

Renowned Member
Apr 13, 2012
163
9
83
Hello Forum,

Referring to this post I found:

https://forum.proxmox.com/threads/find-vms-with-lock.54492/post-251027

It says to install "jq" and use the following command:

Code:
pvesh get /nodes/$(hostname)/qemu --output-format=json | jq -cr '.[] | select(.["lock"]) | .["vmid"]'

to check for VM's with a lock on them.

I have a cluster of Proxmox servers. Will the above command look at all VM's in my cluster and report on any VM in my cluster that has a lock on them?

Thank you.
 
No, this only works for one node ($(hostname)). But you can run it for each node in the cluster replacing $(hostname) with the hostname of the node.
In addition to the above API call, you could also use pvesh get /cluster/resources --output-format json and look check for the 'lock' property. This is what the tree in the GUI uses.
 
Last edited:
  • Like
Reactions: greavette
Thanks very much @mira for you reply.

I've checked all my nodes and confirmed none are locked.

But is there a command I can use to lock a VM? I want to test these pvesh commands and confirm they show me a locked VM. I can see in qm help there is an unlock <vmid> command. But I don't see a corresponding qm lock command.

Thank you.
 
Last edited:
That's not possible via a command, but you can add a lock line in the config, e.g. lock: backup. You can then unlock it again either via qm unlock or by deleting the line in the config.
Only do that with a test VM.
 

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!