Hi Daniel
Thank you very much for your answer. Apologies for late reply.
I got it working but I had to do a few modifications.
Usually, qemu-kvm runs as a qemu user as configured in /etc/libvirt/qemu.conf (user/group parameters). My QCOW files were owned by root during this experiment (usually I set them to be owned by qemu user). Once a VM starts, the ownership is changed to qemu and it keeps that way until I try to start the same VM on another hypervisor and lock kicks in. In that moment, the file ownership is changed to root again (observed via watch in 2nd terminal) and the VM goes read only.
I can do a workaround and then lock works normally (no ro-VM) if I do the following:
- set 0777 permissions on the QEMU file
- change user/group parameters in qemu.conf to root and restart libvirtd
I like to have a bit of a security so I searched through qemu.conf file and found option dynamic_ownership. The option is set to 1 by default. I set it to 0 and then changed ownership of the image files to qemu, set user/group in qemu.conf
to qemu, normal permissions on the files and finally restarted libvirtd. After that, lock works as expected.
The side effect is that if you want to do template based provisioning via python-libvirt based app or from the shell by using virt-sysprep, virt-clone or some other libvirt/libguestfs based app and you want to modify a VM after cloning (hostname/network/vCPU/etc..), it will throw an exception - permission denied on the image file. This one was solved by looking at
https://access.redhat.com/solutions/2110391 and it works great once applied. During all this time, SELinux was disabled.
I would like to take this opportunity to personally thank you and the team in Red Hat for all hard work on libvirt and libvirt-based tools. I heavily use python-libvirt module and what I can say is that if you don't have RHEV-M/oVirt as a single
pane of glass for your virtualization layer, it helps you a great deal in managing and inspecting (and making statistics!) of a large pool of KVM hypervisors. Please keep up a good work!
Regards,
Branimir