# Qemu-kvm: Failed to get "write" lock

**URL:** <https://forum.opennebula.io/t/qemu-kvm-failed-to-get-write-lock/7771>\
**Category:** Operations\
**Created:** [October 28, 2019, 5:26pm UTC](https://forum.opennebula.io/t/qemu-kvm-failed-to-get-write-lock/7771 "2019-10-28T17:26:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![modir](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/modir/32/6116_2.png) [@modir](https://forum.opennebula.io/u/modir)\
**Post date:** [October 28, 2019, 5:26pm UTC](https://forum.opennebula.io/t/qemu-kvm-failed-to-get-write-lock/7771/1 "2019-10-28T17:26:57Z")

</div>

I created a new node on our infrastructure and now whenever I want to start a VM on this new node I get these error messages:

```
error: qemu unexpectedly closed the monitor: 2019-10-28T17:09:21.244860Z qemu-kvm: -drive file=/var/lib/one//datastores/106/214/disk.0,format=qcow2,if=none,id=drive-ide0-0-0,cache=none: Failed to get "write" lock
Mon Oct 28 18:09:34 2019 [Z0][VMM][I]: Is another process using the image [/var/lib/one//datastores/106/214/disk.0]?
Mon Oct 28 18:09:34 2019 [Z0][VMM][E]: Could not create domain from /var/lib/one//datastores/106/214/deployment.38

```

Interestingly the file deployment.38 exists afterwards. And when I run lsof on this file afterwards I have no process using this file. This datastore is on NFS and we have opennebula 5.8.5.

Does anybody have some more ideas how I could investigate what exactly is going on?

UPDATE: I tested it now with a VM on the ceph store and there it works. So it must be something related to NFS.

---

<div class="post-metadata">

**Author:** ![svega](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/svega/32/5504_2.png) [@svega](https://forum.opennebula.io/u/svega)\
**Post date:** [October 31, 2019, 6:17am UTC](https://forum.opennebula.io/t/qemu-kvm-failed-to-get-write-lock/7771/2 "2019-10-31T06:17:43Z")

</div>

Could you share the mount options for that NFS mount? Does it only happen with one image or several?

---

<div class="post-metadata">

**Author:** ![modir](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/modir/32/6116_2.png) [@modir](https://forum.opennebula.io/u/modir)\
**Post date:** [March 5, 2020, 2:34pm UTC](https://forum.opennebula.io/t/qemu-kvm-failed-to-get-write-lock/7771/3 "2020-03-05T14:34:49Z")

</div>

Sure. this are the mount options:  
`192.168.11.55:/volume1/datastore1 /var/lib/one/datastores/1 nfs rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.11.55,mountvers=3,mountport=892,mountproto=udp,local_lock=none,addr=192.168.11.55 0 0`

And we have the issue with 3 or 4 VMs but not more.

---

<div class="post-metadata">

**Author:** ![perrfect](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@perrfect](https://forum.opennebula.io/u/perrfect)\
**Post date:** [March 5, 2020, 2:49pm UTC](https://forum.opennebula.io/t/qemu-kvm-failed-to-get-write-lock/7771/4 "2020-03-05T14:49:06Z")

</div>

I have same problem, but i’m testing host\_hook. And when i’m stopping a libvirtd service on one node in a cluster i get the error:

> Message received: LOG I 108 Command execution fail: cat \<\< EOT | /var/tmp/one/vmm/kvm/deploy ‘/var/lib/one//datastores/123/108/deployment.3’ ‘node1’ 108 node2  
> Message received: LOG I 108 error: Failed to create domain from /var/lib/one//datastores/123/108/deployment.3  
> Message received: LOG I 108 error: internal error: qemu unexpectedly closed the monitor: 2020-03-05T14:39:36.080776Z qemu-kvm: -drive file=/var/lib/one//datastores/123/108/disk.0,format=qcow2,if=none,id=drive-scsi0-0-0-0,cache=none: Failed to get “write” lock

---

<div class="post-metadata">

**Author:** ![cgonzalez](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/cgonzalez/32/7096_2.png) [@cgonzalez](https://forum.opennebula.io/u/cgonzalez)\
**Post date:** [March 5, 2020, 4:03pm UTC](https://forum.opennebula.io/t/qemu-kvm-failed-to-get-write-lock/7771/5 "2020-03-05T16:03:01Z")

</div>

Hello,

QEMU have a locking method for images in use if you use a shared filesystem which supports locking. The locked files need some time to expire as NFS server gives some time to NFS clients (hypervisors) to recover in case of incident.

You can disable locking support on mounted volumes on hypervisors by adding `nolock` option at mount option at fstab or decrease these timeouts on NFS server (check `--lease-time seconds` and `--grace-time seconds` options).

---

<div class="post-metadata">

**Author:** ![modir](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/modir/32/6116_2.png) [@modir](https://forum.opennebula.io/u/modir)\
**Post date:** [March 5, 2020, 4:22pm UTC](https://forum.opennebula.io/t/qemu-kvm-failed-to-get-write-lock/7771/6 "2020-03-05T16:22:04Z")

</div>

In the fstab output above you can see that I have set “timeout=600”. Which would mean 10 minutes. My test VM is now shut down for 2 hours and still can not be started due to the lock problem. From my point of view it looks like there is another problem.

---

<div class="post-metadata">

**Author:** ![modir](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/modir/32/6116_2.png) [@modir](https://forum.opennebula.io/u/modir)\
**Post date:** [April 5, 2020, 9:38pm UTC](https://forum.opennebula.io/t/qemu-kvm-failed-to-get-write-lock/7771/7 "2020-04-05T21:38:51Z")

</div>

I have opened a case now with Synology because the NFS share is on a Synology NAS. After several investigations they said that the problem must be with qemu. From their side all is fine. Maybe someone else knows. more.
