Red Hat Bugzilla – Bug 768268
Libvirt fail to detach PF/VF device when the address of pci device described as decimalism
Last modified: 2012-06-20 02:39:09 EDT
Description of problem: Describe the address of PCI device with decimalism. Hotplug PF/VF successfully,but libvirt fail when hot unplug PF/VF with message "error: no such device in <guest>" Version-Release number of selected component (if applicable): libvirt-0.9.8-1.el6.x86_64 libvirt-client-0.9.8-1.el6.x86_64 libvirt-python-0.9.8-1.el6.x86_64 virt-manager-0.9.0-7.el6.x86_64 kernel-2.6.32-220.el6.x86_64 qemu-kvm-0.12.1.2-2.209.el6.x86_64 How reproducible: always Steps to Reproduce: 1.Prepare a PF xml like this. #cat PF.xml <hostdev mode='subsystem' type='pci' managed='yes'> <source> <address bus='3' slot='0' function='1'/> </source> </hostdev> 2.Start a guest. #virsh start kvm-rhel6.1-i386 3.Hot plug the PF. # virsh attach-device kvm-rhel6.1-i386 PF.xml Device attached successfully 4.Hot unplug the PF. # virsh detach-device kvm-rhel6.1-i386 PF.xml Actual results: error: no such device in kvm-rhel6.1-i386 Expected results: The PF detached successfully Additional info: 1.It works well on libvirt-0.9.4-23 2.The detach device will success if update the address with hex,like this: #cat PF.xml <hostdev mode='subsystem' type='pci' managed='yes'> <source> <address bus='0x03' slot='0x0' function='0x01'/> </source> </hostdev>
This issue is introduced in commit ea7182c2, the cmdDetachDevice function uses new vshCompleteXMLFromDomain function to find such device in domain. Alex
commit c001eb5bbefd42b3976fe95ce7b9c53dd69a49a0 Author: Osier Yang <jyang@redhat.com> Date: Tue Feb 7 23:56:08 2012 +0800 virsh: Do not check the input XML at virsh layer for cmdDetachDevice Any device XML doesn't use the same order as libvirt generates, or uses decimal for attributes like "slot" of "<address>" will cause device detaching to fail, as virsh compares the XML simply earlier in strict manner before internal parsing. This is regression introduced by ea7182c.
Verified with libvirt-0.9.10-0rc2.el6.x86_64.rpm
According steps of comment 0, tested with libvirt-0.9.10-1.el6.x86_64 and it passed. virsh # detach-device rhel6 PF.xml Device detached successfully
Technical note added. If any revisions are required, please edit the "Technical Notes" field accordingly. All revisions will be proofread by the Engineering Content Services team. New Contents: No documentation needed.
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. http://rhn.redhat.com/errata/RHSA-2012-0748.html