Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 499577

Summary: RHEL 5.4 vt-d: libvirt's qemu driver interprets the <hostdev> "managed" attribute incorrectly
Product: Red Hat Enterprise Linux 5 Reporter: Mark McLoughlin <markmc>
Component: libvirtAssignee: Daniel Berrangé <berrange>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.4CC: berrange, clalance, crobinso, nzhang, veillard, virt-maint, xen-maint
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 499386 Environment:
Last Closed: 2009-09-02 09:21:17 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:

Description Mark McLoughlin 2009-05-07 09:45:05 UTC
+++ This bug was initially created as a clone of Bug #499386 +++

When using virt-install --host-device, the device XML looks like this:

    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0' bus='0' slot='25' function='0'/>
      </source>
    </hostdev>

With managed='yes', libvirt doesn't detach or reset the device before starting the guest, nor does it it re-attach it when the guest is shut down.

AFAICS, this is just a typo and we actually want "managed='no'"

--- Additional comment from markmc on 2009-05-06 09:59:13 EDT ---

Okay, it turns out "managed='yes'" is supposed to detach/reset/reattach the device, not "managed='no'"

The fix should be as simple as:

@@ -1215,7 +1215,7 @@ static int qemuPrepareHostDevices(virConnectPtr conn,
         if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
             continue;
 
-        if (!hostdev->managed) {
+        if (hostdev->managed) {
             pciDevice *dev = pciGetDevice(conn,
                                           hostdev->source.subsys.u.pci.domain,
                                           hostdev->source.subsys.u.pci.bus,

--- Additional comment from markmc on 2009-05-06 11:41:12 EDT ---

Patch posted to libvir-list:

  http://www.redhat.com/archives/libvir-list/2009-May/msg00111.html

--- Additional comment from crobinso on 2009-05-06 12:37:38 EDT ---

Being built into libvirt-0.6.2-6.fc11 atm.

--- Additional comment from markmc on 2009-05-06 16:17:32 EDT ---

Tag request: https://fedorahosted.org/rel-eng/ticket/1748

* Wed May  6 2009 Mark McLoughlin <markmc> - 0.6.2-5.fc11
- Fix handling of <hostdev managed='yes'> (bug #499386)

--- Additional comment from markmc on 2009-05-06 17:37:37 EDT ---

Tagged now

Comment 1 Daniel Veillard 2009-06-04 14:14:03 UTC
This has been applied upstream long ago,

Daniel

Comment 2 Daniel Veillard 2009-06-04 16:43:02 UTC
libvirt-0.6.3-5.el5 has been built in dist-5E-qu-candidate with the fix,

Daniel

Comment 4 Nan Zhang 2009-06-08 09:40:09 UTC
[root@dhcp-66-70-85 ~]# virsh nodedev-list --tree

Add hostdev section to domain xml with managed='yes':

    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address bus='0x02' slot='0x00' function='0x00'/>
      </source>
    </hostdev>

[root@dhcp-66-70-85 ~]# virsh edit demo
Domain demo XML configuration edited.

[root@dhcp-66-70-85 ~]# virsh nodedev-dettach pci_14e4_167a
Device pci_14e4_167a dettached

[root@dhcp-66-70-85 ~]# virsh nodedev-reset pci_14e4_167a
Device pci_14e4_167a reset

[root@dhcp-66-70-85 ~]# virsh nodedev-reattach pci_14e4_167a
Device pci_14e4_167a re-attached


Verified with libvirt 0.6.3-6 on RHEL-5.4. Fixed.

Comment 6 errata-xmlrpc 2009-09-02 09:21:17 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHEA-2009-1269.html