RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1155887 - [Doc]Only expose managed attribute for PCI hostdev
Summary: [Doc]Only expose managed attribute for PCI hostdev
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.1
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Erik Skultety
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-23 05:59 UTC by Hu Jianwei
Modified: 2015-11-19 05:54 UTC (History)
5 users (show)

Fixed In Version: libvirt-1.2.14-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-11-19 05:54:25 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2202 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2015-11-19 08:17:58 UTC

Description Hu Jianwei 2014-10-23 05:59:08 UTC
Description
libvirt should only use managed='yes/no' on PCI host device in <hostdev>
managed option is meaningless for usb and scsi type

Version:
libvirt-1.2.8-5.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
[root@localhost ~]# lsusb| grep SanDisk
Bus 002 Device 004: ID 0781:5580 SanDisk Corp. SDCZ80 Flash Drive
[root@localhost ~]#
[root@localhost ~]# virsh dumpxml r7 |grep "/hostdev" -B6
    <hostdev mode='subsystem' type='usb' managed='no'>
      <source>
        <vendor id='0x0781'/>
        <product id='0x5580'/>
        <address bus='2' device='4'/>
      </source>
    </hostdev>
[root@localhost ~]# virsh start r7
Domain r7 started

In guest:
[root@oolong ~]# lsusb
Bus 001 Device 002: ID 0781:5580 SanDisk Corp. SDCZ80 Flash Drive
...

Actual results:
As above shown steps.

Expected results:
For usb and scsi type in <hostdev>, should remove meaningless managed option from XML at least.

Additional info:
I found libvirt only check the "managed=yes/no" on PCI host device.

such as in virHostdevPreparePCIDevices():
    /* Loop 2: detach managed devices (i.e. bind to appropriate stub driver) */
    for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
        virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
        if (virPCIDeviceGetManaged(dev) &&
            virPCIDeviceDetach(dev, hostdev_mgr->activePCIHostdevs, NULL) < 0)
            goto reattachdevs;
    }

Comment 2 Erik Skultety 2015-02-24 12:10:01 UTC
Host devices (like most types of devices) are formatted into the XML description uniformly. That means, they're represented by certain internal structures which have all the relevant elements defined and all the irrelevant elements cleared and formatting behaves accordingly.
Now fixing this issue would not only require tweaking conditions in formatting, but more importantly switching from simple Boolean logic to ternary logic.
If the user's not 100% sure, http://libvirt.org/formatdomain.html#elementsHostDevSubsys describes the meaning of attributes and elements. Even if there's 'managed' attribute set to 'yes' when dealing with USB/SCSI devices, it will be ignored silently, no unexpected behaviour.

Comment 3 Hu Jianwei 2015-02-27 02:59:55 UTC
(In reply to Erik Skultety from comment #2)
> Host devices (like most types of devices) are formatted into the XML
> description uniformly. That means, they're represented by certain internal
> structures which have all the relevant elements defined and all the
> irrelevant elements cleared and formatting behaves accordingly.
Based on your above explanation, I think libvirt should remove "managed" attribute from XML layer for USB/SCSI devices during using "dumpxml" command at least, like:

[root@localhost ~]# virsh dumpxml r71
...
    <hostdev mode='subsystem' type='usb'>
      <source>
        <vendor id='0x0781'/>
        <product id='0x5580'/>
        <address bus='4' device='2'/>
      </source>
      <alias name='hostdev0'/>
    </hostdev>
...
Contrarily, dumpxml can leave it on after adding some relevant codes if it's possible.

> Now fixing this issue would not only require tweaking conditions in
> formatting, but more importantly switching from simple Boolean logic to
> ternary logic.
> If the user's not 100% sure,
> http://libvirt.org/formatdomain.html#elementsHostDevSubsys describes the
> meaning of attributes and elements. Even if there's 'managed' attribute set
> to 'yes' when dealing with USB/SCSI devices, it will be ignored silently, no
> unexpected behaviour.
Consumer saw it from dumpxml's output, so people will believe it's a useful attribute, but it's useless for USB/SCSI in background, it's hard to understand.

Comment 4 Erik Skultety 2015-02-27 12:00:04 UTC
Rather than special casing hostdev device types and attributes (both of which might as well grow in count sometime in the future), I proposed an upstream patch https://www.redhat.com/archives/libvir-list/2015-February/msg01210.html to update the documentation to make the usage/appearance of 'managed' attribute more clear.

Comment 5 Hu Jianwei 2015-02-28 01:54:52 UTC
Thanks, I changed it as a doc bug, reassigned it to you, please help me fix it.

Comment 6 Erik Skultety 2015-03-02 11:13:57 UTC
Fixed upstream:

commit ccfe9e480986c075a6a04f7792a5b30350396d83
Author: Erik Skultety <eskultet>
Date:   Fri Feb 27 12:45:57 2015 +0100

    docs: add a note that attr 'managed' is only used by PCI devices
    
    Our documentation isn't 100% clear about hostdev 'managed' attribute usage,
    because it only makes sense to use it with PCI devices, yet we format
    this attribute to all hostdev devices. By adding a note into the docs,
    we can possibly avoid confusion from customer's side and also avoid a solution
    using ternary logic.

v1.2.13-22-gccfe9e4

Comment 10 hongming 2015-07-13 07:39:57 UTC
Verify it as follows.The result is expected. Move its status to VERIFIED.


# rpm -q libvirt libvirt-debuginfo
libvirt-1.2.17-1.el7.x86_64
libvirt-debuginfo-1.2.15-2.el7.x86_64


# vim /usr/share/doc/libvirt-docs-1.2.17/html/formatdomain.html

2909         <p>
2910           Note: The <code>managed</code> attribute is only used with PCI devices
2911           and is ignored by all the other device types, thus setting
2912           <code>managed</code> explicitly with other than PCI device has the same
2913           effect as omitting it.
2914         </p>

Comment 12 errata-xmlrpc 2015-11-19 05:54:25 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.

https://rhn.redhat.com/errata/RHBA-2015-2202.html


Note You need to log in before you can comment on or make changes to this bug.