Virtual Machine Lock Manager
The virtual machine lock manager is a daemon which will ensure that a virtual machine's disk image cannot be written to by two QEMU/KVM processes at the same time. It provides protection against starting the same virtual machine twice, or adding the same disk to two different virtual machines.
- Name: Daniel Berrange
- Email: berrange-at-redhat-dot-com>
- Targeted release: Fedora 16
- Last updated: (DATE)
- Percentage of completion: 80%
Virtual machines running via the QEMU/KVM platform do not currently acquire any kind of lock when starting up. This means it is possible for the same virtual machine to be accidentally started more than once, or for the same disk image to be accidentally added to two different virtual machines. The result of such a mistake is likely to be catastrophic destruction of the virtual machines filesystem.
The virtual machine lock manager is a framework embedded in the libvirtd daemon that allows for pluggable locking mechanisms. Out of the box, libvirt will provide a daemon "virtlockd" that will maintain locks for all running virtual machines on a host. This will protect against adding the same disk to two different virtual machines, and protect against libvirtd bugs where it might "forget" about a previously running virtual machine. If the administrator mounts a suitable shared filesystem (eg, NFS) in /var/lib/libvirt/lockd then the lock manager protection will be extended to all hosts shared that filesystem.
There will also be a separate, 3rd party, lock manager implementation available called "sanlock". This is expected to be the subject of a separate Fedora feature, so will not be discussed here further.
Benefit to Fedora
Hosts running virtual machines for QEMU/KVM will have much stronger protection against administrator host/cluster configuration mistakes. This will reduce the risk that a virtual machines' disk image will become corrupted as a result.
The changes are confined to the libvirt package. It will include
- A new daemon 'virtlockd' with systemd service + socket files - virtlockd will be enabled by default on all hosts currently running 'libvirtd' - The /etc/libvirt/qemu.conf file will gain a configuration parameter to set the lock manager implementation
How To Test
There are no special hardware requirements for testing this feature, beyond those already required for running QEMU/KVM virtual machines.
Single host testing:
- Install the standard libvirt + QEMU/KVM virtualization packages - Provision two virtual machines - Create a third disk image (eg dd if=/dev/zero of=/var/lib/libvirt/images/extra.img bs=1M count=100) - Add the following XML to the configuration of both virtual machines
0. What special hardware / data / etc. is needed (if any)? 1. How do I prepare my system to test this feature? What packages need to be installed, config files edited, etc.? 2. What specific actions do I perform to check that the feature is working like it's supposed to? 3. What are the expected results of those actions? -->