Libvirt (virsh) cannot acquire state change lock error explained

By | January 6, 2012

So, I’ve been dealing with this libvirt state change lock problem quite for a while now. I have a solution to fix this, but I always wanted to understand what’s causing this problem. I found the answer (with explanation) in a forum thread. Check this out to find what’s really going on.

If an async job run on a domain will stop the domain at the end of the
job, a concurrently run query job can hang in qemu monitor nothing can
be done with that domain from this point on. An attempt to start such
domain results in “Timed out during operation: cannot acquire state
change lock” error.

However, quite a few things have to happen at the right time… There
must be an async job running, which stops a domain at the end. This race
was with dump –crash but other similar jobs, such as (managed)save and
migration, should be able to trigger this bug as well. While this async
job is processing its last monitor command, that is a query-migrate to
which qemu replies with status “completed”, a new libvirt API that
results in a query job must arrive and stay waiting until the
query-migrate command finishes. Once query-migrate is done but before
the async job closes qemu monitor while stopping the domain, the other
thread needs to wake up and call qemuMonitorSend to send its command to
qemu. Before qemu gets a chance to respond to this command, the async
job needs to close the monitor. At this point, the query job thread is
waiting for a condition that no-one will ever signal so it never
finishes the job.

CREDITS:http://comments.gmane.org/gmane.comp.emulators.libvirt/50072

If you like this article, then please consider sharing it. Sharing really inspires us to do things much better!!

Leave a Reply

Your email address will not be published. Required fields are marked *