Hide Forgot
description of problem: some issue when we try to cold-unplug, hot-plug... a lease device Version-Release number of selected component (if applicable): libvirt-1.2.8-10.el7.x86_64 How reproducible: 100% Steps to Reproduce: 1.prepare a guest without lease device settings and then use attach-device to coldplug a lease: # cat deviceleases.xml <lease> <lockspace>somearea</lockspace> <key>somekey</key> <target path='/some/lease/path' offset='1024'/> </lease> # virsh attach-device test4 deviceleases.xml --config Device attached successfully 2.check the xml: # virsh dumpxml test4 --inactive <lease> <lockspace>somearea</lockspace> <key>somekey</key> <target path='/some/lease/path' offset='1024'/> </lease> 3.# virsh detach-device test4 deviceleases.xml --config error: Failed to detach device from deviceleases.xml error: invalid argument: Lease somekey in lockspace somearea does not exist Actual results: cannot cold-unplug a lease device but can cold-plug it Expected results: can cold-unplug a lease device The main cause of this issue is because: when we set lockspace in XML, virDomainLeaseIndex will always return -1 although the two lease are the same. This will also cause can attach a lot of same lease with no error.
So I've just pushed the patch upstream: commit 046d82d72fa7a2daf2bcb39af3d1a5c3d22e23bd Author: Luyao Huang <lhuang> AuthorDate: Mon Dec 15 14:46:28 2014 +0800 Commit: Michal Privoznik <mprivozn> CommitDate: Mon Dec 15 14:19:38 2014 +0100 conf: fix virDomainLeaseIndex logic https://bugzilla.redhat.com/show_bug.cgi?id=1174096 When both parameter have lockspaces present, virDomainLeaseIndex always returns -1 even there is a lease the same with the one we check. This is due to broken logic in 'if-else' statement. Signed-off-by: Luyao Huang <lhuang> Signed-off-by: Michal Privoznik <mprivozn> v1.2.11-13-g046d82d
Verified on libvirt-1.2.16-1.el7.x86_64 Steps 1. configure lock manager as sanlock # tail -5 /etc/libvirt/qemu-sanlock.conf user = "sanlock" group = "sanlock" host_id = 1 auto_disk_leases = 0 disk_lease_dir = "/var/lib/libvirt/sanlock" require_lease_for_disks = 1 #tail -1 /etc/libvirt/qemu.conf lock_manager = "sanlock" # getsebool -a | grep sanlock sanlock_use_nfs --> on virt_use_sanlock --> on #service sanlock start #service libvirtd start 2. create a lease manually 3. prepare an inactive domain, then do attach-device, detach-device with flag config, current, persistent # virsh attach-device simple lease.xml --config Device attached successfully # virsh dumpxml simple | grep lease -a6 <lease> <lockspace>TEST_LS</lockspace> <key>test-disk-resource-lock</key> <target path='/var/lib/libvirt/sanlock/test-disk-resource-lock'/> </lease> # virsh detach-device simple lease.xml --config Device detached successfully # virsh dumpxml simple | grep lease -a6 # virsh attach-device simple lease.xml --current Device attached successfully # virsh dumpxml simple | grep lease -a6 <lease> <lockspace>TEST_LS</lockspace> <key>test-disk-resource-lock</key> <target path='/var/lib/libvirt/sanlock/test-disk-resource-lock'/> </lease> # virsh detach-device simple lease.xml --current Device detached successfully # virsh dumpxml simple | grep lease -a6 # virsh attach-device simple lease.xml --persistent Device attached successfully # virsh dumpxml simple | grep lease -a6 <lease> <lockspace>TEST_LS</lockspace> <key>test-disk-resource-lock</key> <target path='/var/lib/libvirt/sanlock/test-disk-resource-lock'/> </lease> # virsh detach-device simple lease.xml --persistent Device detached successfully # virsh dumpxml simple | grep lease -a6 Also check attach-device, detach-device on active domain, all work well.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHBA-2015-2202.html