Bug 768268

Summary: Libvirt fail to detach PF/VF device when the address of pci device described as decimalism
Product: Red Hat Enterprise Linux 6 Reporter: yuping zhang <yupzhang>
Component: libvirtAssignee: Osier Yang <jyang>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 6.3CC: acathrow, ajia, dallan, dyuan, mzhan, rwu, zhpeng
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-0.9.10-1.el6 Doc Type: Bug Fix
Doc Text:
No documentation needed.
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 06:39:09 UTC Type: ---
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:    
Bug Blocks: 748405    

Description yuping zhang 2011-12-16 08:17:28 UTC
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>

Comment 3 Alex Jia 2011-12-16 08:25:27 UTC
This issue is introduced in commit ea7182c2, the cmdDetachDevice function uses new vshCompleteXMLFromDomain function to find such device in domain.


Alex

Comment 6 Osier Yang 2012-02-08 01:47:16 UTC
commit c001eb5bbefd42b3976fe95ce7b9c53dd69a49a0
Author: Osier Yang <jyang>
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.

Comment 7 zhpeng 2012-02-09 03:06:49 UTC
Verified with libvirt-0.9.10-0rc2.el6.x86_64.rpm

Comment 10 zhpeng 2012-02-15 06:10:59 UTC
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

Comment 11 Osier Yang 2012-05-04 07:24:38 UTC
    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.

Comment 13 errata-xmlrpc 2012-06-20 06:39:09 UTC
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