Bug 1553075
Summary: | User-aliases not cleared on detach-device | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Arik <ahadas> | ||||||
Component: | libvirt | Assignee: | Michal Privoznik <mprivozn> | ||||||
Status: | CLOSED ERRATA | QA Contact: | Han Han <hhan> | ||||||
Severity: | urgent | Docs Contact: | |||||||
Priority: | urgent | ||||||||
Version: | 7.6 | CC: | dyuan, jdenemar, jherrman, jiyan, jsuchane, lmen, michal.skrivanek, pkrempa, salmy, spower, xuzhang, yafu, yalzhang | ||||||
Target Milestone: | rc | Keywords: | Upstream, ZStream | ||||||
Target Release: | --- | ||||||||
Hardware: | Unspecified | ||||||||
OS: | Unspecified | ||||||||
Whiteboard: | |||||||||
Fixed In Version: | libvirt-4.3.0-1.el7 | Doc Type: | Bug Fix | ||||||
Doc Text: |
Previously, the libvirt service used the incorrect XML configuration when checking for a duplicate user alias. As a consequence, hot-plugging a device with a unique alias to a guest virtual machine in some cases failed with a "non unique alias" error message. With this update, libvirt uses the correct XML files for verifying the device alias, which prevents the problem from occurring.
|
Story Points: | --- | ||||||
Clone Of: | |||||||||
: | 1554962 (view as bug list) | Environment: | |||||||
Last Closed: | 2018-10-30 09:53:14 UTC | Type: | Bug | ||||||
Regression: | --- | Mount Type: | --- | ||||||
Documentation: | --- | CRM: | |||||||
Verified Versions: | Category: | --- | |||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||
Embargoed: | |||||||||
Bug Depends On: | 1543775 | ||||||||
Bug Blocks: | 1554962 | ||||||||
Attachments: |
|
Description
Arik
2018-03-08 09:00:51 UTC
Could you attach the domain XML after step 2? Created attachment 1405767 [details]
domain xml after starting the vm
Created attachment 1405768 [details]
domain xml after unplugging the nic
(In reply to Jiri Denemark from comment #2) > Could you attach the domain XML after step 2? Done. And the error on step 3 is: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/vdsm/virt/vm.py", line 2907, in hotplugNic self._dom.attachDevice(nicXml) File "/usr/lib/python2.7/site-packages/vdsm/virt/virdomain.py", line 98, in f ret = attr(*args, **kwargs) File "/usr/lib/python2.7/site-packages/vdsm/common/libvirtconnection.py", line 130, in wrapper ret = f(*args, **kwargs) File "/usr/lib/python2.7/site-packages/vdsm/common/function.py", line 92, in wrapper return func(inst, *args, **kwargs) File "/usr/lib64/python2.7/site-packages/libvirt.py", line 570, in attachDevice if ret == -1: raise libvirtError ('virDomainAttachDevice() failed', dom=self) libvirtError: XML error: non unique alias detected: ua-e3e109ca-a89a-45af-b240-503efeb497ef I was able to reproduce this. The important part is that the device must be present in the persistent config and detached from the live one. Then virsh attach-device *--live* fails because it finds a conflict with the persistent definition. This makes no sense. It looks like the following function is the problem ... int virDomainDeviceValidateAliasForHotplug(virDomainObjPtr vm, virDomainDeviceDefPtr dev, unsigned int flags) { virDomainDefPtr persDef = NULL; virDomainDefPtr liveDef = NULL; if (virDomainObjGetDefs(vm, flags, &liveDef, &persDef) < 0) return -1; if (persDef && virDomainDeviceValidateAliasImpl(vm->def, dev) < 0) return -1; As vm->def is in fact the live definition if the VM is running ... if (liveDef && virDomainDeviceValidateAliasImpl(vm->newDef, dev) < 0) vm->newDef is the persistent definition here. It also may be NULL for transient VMs, so this will also crash in certain configs. return -1; return 0; } Patch proposed upstream: https://www.redhat.com/archives/libvir-list/2018-March/msg00466.html I've just merged the patch upstream: commit e5673ed44465edcfccdd906158136ad8dcb94b9b Author: Michal Privoznik <mprivozn> AuthorDate: Fri Mar 9 08:31:44 2018 +0100 Commit: Michal Privoznik <mprivozn> CommitDate: Mon Mar 12 13:27:24 2018 +0100 virDomainDeviceValidateAliasForHotplug: Use correct domain defintion https://bugzilla.redhat.com/show_bug.cgi?id=1553075 For some weird reason this function is getting live and persistent def for domain but then accesses vm->def and vm->newDef directly. This is rather unsafe as we can be accessing NULL pointer. Signed-off-by: Michal Privoznik <mprivozn> v4.1.0-91-ge5673ed44 Bug 1543775 needs to be fixed too, otherwise this patch will break device hotplug even more. Paste the reproducing steps in pure libvirt here. Version: kernel-3.10.0-860.el7.x86_64 qemu-kvm-rhev-2.10.0-21.el7.x86_64 libvirt-3.9.0-14.el7.x86_64 Steps to reproduce: 1. Prepare a shutdown VM with the following conf: # virsh domstate test1 shut off # virsh dumpxml test1 --inactive |grep "<interface" -A10 <interface type='bridge'> <mac address='00:1a:4a:16:01:00'/> <source bridge='br0'/> <model type='virtio'/> <filterref filter='vdsm-no-mac-spoofing'/> <alias name='ua-e3e109ca-a89a-45af-b240-503efeb497ef'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> 2. Start VM and hot-unplug the interface device # cat nic.xml <interface type='bridge'> <mac address='00:1a:4a:16:01:00'/> <source bridge='br0'/> <target dev='vnet0'/> <model type='virtio'/> <filterref filter='vdsm-no-mac-spoofing'> </filterref> <alias name='ua-e3e109ca-a89a-45af-b240-503efeb497ef'/> </interface> # virsh start test1 Domain test1 started # virsh detach-device test1 nic.xml Device detached successfully # virsh dumpxml test1 |grep "<interface" -A10 <interface type='bridge'> <mac address='00:1a:4a:16:01:00'/> <source bridge='br0'/> <target dev='vnet0'/> <model type='virtio'/> <filterref filter='vdsm-no-mac-spoofing'/> <alias name='ua-e3e109ca-a89a-45af-b240-503efeb497ef'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> 3. Hot-plug the interface again # virsh attach-device test1 nic.xml error: Failed to attach device from nic.xml error: XML error: non unique alias detected: ua-e3e109ca-a89a-45af-b240-503efeb497ef Paste another scenario related to this issue here, which can be considered when verifying this bug. Description: Cold-plugging disk with same alias that has existed in another 'optional' disk in dumpxml of VM do not raise error Version: kernel-3.10.0-860.el7.x86_64 qemu-kvm-rhev-2.10.0-21.el7.x86_64 libvirt-3.9.0-14.virtcov.el7.x86_64 Steps: 1. Prepare a shutdown VM with the following VM, and start VM to confirm there is no error info raised. # ll /var/lib/libvirt/images/ total 7054660 -rw-r--r--. 1 root root 1442119680 Feb 27 04:01 optionalRHEL-7.5-x86_64-latest.qcow2 -rw-------. 1 root root 1428029440 Mar 11 23:16 test1RHEL-7.5-x86_64-latest-clone.qcow2 # virsh domstate test1 shut off # virsh dumpxml test1 --inactive grep "<disk" -A7 <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/var/lib/libvirt/images/test1RHEL-7.5-x86_64-latest.qcow2'/> <target dev='hda' bus='usb'/> <alias name='ua-disk1'/> <address type='usb' bus='0' port='1.3'/> </disk> <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/var/lib/libvirt/images/0.qcow2' startupPolicy='optional'/> <target dev='hdc' bus='usb'/> <alias name='ua-disk2'/> <address type='usb' bus='0' port='1.4'/> </disk> # virsh start test1 Domain test1 started # virsh dumpxml test1 |grep "<disk" -A7 <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/var/lib/libvirt/images/test1RHEL-7.5-x86_64-latest.qcow2'/> <backingStore/> <target dev='hda' bus='usb'/> <alias name='ua-disk1'/> <address type='usb' bus='0' port='1.3'/> </disk> 2. Hot-plug / Cold-plug a virtual disk with alias that is same with 'ua-disk2', hot-plugging failed while cold-plugging succeeded # cat disk.xml <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/var/lib/libvirt/images/optionalRHEL-7.5-x86_64-latest.qcow2'/> <target dev='hdb' bus='usb'/> <alias name='ua-disk2'/> </disk> # virsh attach-device test1 disk.xml error: Failed to attach device from disk.xml error: XML error: non unique alias detected: ua-disk2 # virsh attach-device test1 disk.xml --config Device attached successfully 3. Restart VM # virsh destroy test1 Domain test1 destroyed # virsh start test1 error: Failed to start domain test1 error: XML error: non unique alias detected: ua-disk2 # virsh dumpxml test1 --inactive|grep "<disk" -A7 <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/var/lib/libvirt/images/test1RHEL-7.5-x86_64-latest.qcow2'/> <target dev='hda' bus='usb'/> <alias name='ua-disk1'/> <address type='usb' bus='0' port='1.3'/> </disk> <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/var/lib/libvirt/images/optionalRHEL-7.5-x86_64-latest.qcow2'/> <target dev='hdb' bus='usb'/> <alias name='ua-disk2'/> <address type='usb' bus='0' port='1.5'/> </disk> <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/var/lib/libvirt/images/0.qcow2' startupPolicy='optional'/> <target dev='hdc' bus='usb'/> <alias name='ua-disk2'/> <address type='usb' bus='0' port='1.4'/> </disk> To POST: http://post-office.corp.redhat.com/archives/rhvirt-patches/2018-March/msg00318.html Scratch build to test can be found here: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=15543618 Verified on libvirt-4.5.0-2.virtcov.el7.x86_64 qemu-kvm-rhev-2.12.0-7.el7.x86_64: Prepare a running VM and nic xml with alias: # virsh list --all Id Name State ---------------------------------------------------- 63 nest7.6-1 running # cat /tmp/nic.xml <interface type='network'> <mac address='52:54:00:72:7a:34'/> <source network='default'/> <model type='virtio'/> <alias name='ua-xxx'/> </interface> I. Live attach and detach twice: Sorry for the former incomplete message. Verified on libvirt-4.5.0-2.virtcov.el7.x86_64 qemu-kvm-rhev-2.12.0-7.el7.x86_64: Prepare a running VM and nic xml with alias: # virsh list --all Id Name State ---------------------------------------------------- 63 nest7.6-1 running # cat /tmp/nic.xml <interface type='network'> <mac address='52:54:00:72:7a:34'/> <source network='default'/> <model type='virtio'/> <alias name='ua-09f558d3-1223-4e82-9334-87b1eeb26925'/> </interface> I. Live attach twice, then detach once, attach once and detach twice at last: + virsh attach-device nest7.6-1 /tmp/nic.xml Device attached successfully + virsh attach-device nest7.6-1 /tmp/nic.xml error: Failed to attach device from /tmp/nic.xml error: XML error: non unique alias detected: ua-09f558d3-1223-4e82-9334-87b1eeb26925 + virsh detach-device nest7.6-1 /tmp/nic.xml Device detached successfully + virsh attach-device nest7.6-1 /tmp/nic.xml Device attached successfully + virsh detach-device nest7.6-1 /tmp/nic.xml Device detached successfully + virsh detach-device nest7.6-1 /tmp/nic.xml error: Failed to detach device from /tmp/nic.xml error: device not found: no device matching MAC address 52:54:00:72:7a:34 found II. Test as scenario I with --config: + virsh attach-device nest7.6-1 /tmp/nic.xml --config Device attached successfully + virsh attach-device nest7.6-1 /tmp/nic.xml --config error: Failed to attach device from /tmp/nic.xml error: XML error: non unique alias detected: ua-09f558d3-1223-4e82-9334-87b1eeb26925 + virsh detach-device nest7.6-1 /tmp/nic.xml --config Device detached successfully + virsh attach-device nest7.6-1 /tmp/nic.xml --config Device attached successfully + virsh detach-device nest7.6-1 /tmp/nic.xml --config Device detached successfully + virsh detach-device nest7.6-1 /tmp/nic.xml --config error: Failed to detach device from /tmp/nic.xml error: device not found: no device matching MAC address 52:54:00:72:7a:34 found III. Test as scenario I with --persistent: + virsh attach-device nest7.6-1 /tmp/nic.xml --persistent Device attached successfully + virsh attach-device nest7.6-1 /tmp/nic.xml --persistent error: Failed to attach device from /tmp/nic.xml error: XML error: non unique alias detected: ua-09f558d3-1223-4e82-9334-87b1eeb26925 + virsh detach-device nest7.6-1 /tmp/nic.xml --persistent Device detached successfully + virsh attach-device nest7.6-1 /tmp/nic.xml --persistent Device attached successfully + virsh detach-device nest7.6-1 /tmp/nic.xml --persistent Device detached successfully + virsh detach-device nest7.6-1 /tmp/nic.xml --persistent error: Failed to detach device from /tmp/nic.xml error: device not found: no device matching MAC address 52:54:00:72:7a:34 found Works as expected. Verified. 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://access.redhat.com/errata/RHSA-2018:3113 The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days |