Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
virtlock doesn't work well with images which have backing file
Version-Release number of selected component (if applicable):
libvirt-1.2.8-16.el7.x86_64
How reproducible:
100%
Steps to Reproduce:
1. Enable virtlock
# grep -E -v "^#|^$" /etc/libvirt/qemu.conf
lock_manager = "lockd"
# grep -E -v "^#|^$" /etc/libvirt/qemu-lockd.conf
auto_disk_leases = 1
require_lease_for_disks = 1
file_lockspace_dir = "/var/lib/libvirt/lockd/files"
# systemctl restart virtlockd.service
# systemctl restart libvirtd.service
# ll /var/lib/libvirt/lockd/files
total 0
2. Prepare two image, one is using another one as backing file
# qemu-img create -f qcow2 /var/lib/libvirt/images/rh7.img 1G
Formatting '/var/lib/libvirt/images/rh7.img', fmt=qcow2 size=1073741824 encryption=off cluster_size=65536 lazy_refcounts=off
# qemu-img create -f qcow2 /var/lib/libvirt/images/rh7.s1 -b /var/lib/libvirt/images/rh7.img -o backing_fmt=qcow2
Formatting '/var/lib/libvirt/images/rh7.s1', fmt=qcow2 size=1073741824 backing_file='/var/lib/libvirt/images/rh7.img' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off
3. Prepare two guest use the image created in step2 as source file
# virsh domblklist rh7
Target Source
------------------------------------------------
vda /var/lib/libvirt/images/rh7.img
# virsh domblklist r7
Target Source
------------------------------------------------
vda /var/lib/libvirt/images/rh7.s1
4. Try to boot up two guest
# virsh start rh7
Domain rh7 started
# virsh start r7
Domain r7 started
# ll /var/lib/libvirt/lockd/files
total 0
-rw-------. 1 root root 0 Feb 13 13:44 79c8f5f8e3b82d8ea4bc28e8c8bdcb3a4ce4b2d6fe86feb0fe4e82188f5a9092
-rw-------. 1 root root 0 Feb 13 13:44 cb17138f2c90610971067166bec89c92184bdcf2c3a2201e72ddd946fc9f3af7
Actual results:
as above
Expected results:
Guest r7 shouldn't boot up with rh7.s1 since its backing file rh7.img is using by another guest.
This is the scenario we also try to prevent
Additional info:
So, as turned out in the upstream discussion, this falls out of libvirt scope. While my patches fix the scenario from the comment 0 they will not prevent user from running a domain over a layer somewhere in the middle of the chain. I mean. consider the following backing chain A (top level) -> B -> C -> D (bottom). If you run a domain over A, my patches will lock the whole chain. However, if you configure the domain to run over B, even though my patches will lock all the underlying layers (that is C and D), they will not lock A. In fact, there's no way to the detect whether A even exists and where. Therefore once the domain is started over B, A is effectively invalidated.
Therefore I think this is a misconfiguration and as such falls out of libvirt's scope. However, if somebody disagrees, feel free to reopen with a proper solution outlined.