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 1441291 - USB device passthrough can't be used due to bogus VFIO check
Summary: USB device passthrough can't be used due to bogus VFIO check
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.4
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Erik Skultety
QA Contact: Pei Zhang
URL:
Whiteboard:
: 1446086 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-04-11 15:19 UTC by Daniel Berrangé
Modified: 2017-08-02 01:30 UTC (History)
7 users (show)

Fixed In Version: libvirt-3.2.0-3.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-02 00:05:54 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2017:1846 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2017-08-01 18:02:50 UTC

Description Daniel Berrangé 2017-04-11 15:19:33 UTC
Description of problem:
On a system which lacks support for either the vfio kernel module, or lacks IOMMU hardware, it is no longer possible to use host USB device assignment

eg create a simple guest which contains a single USB hostdev:


    <hostdev mode='subsystem' type='usb' managed='no'>
      <source startupPolicy='optional'>
        <vendor id='0x1050'/>
        <product id='0x0010'/>
      </source>
      <address type='usb' bus='0' port='4'/>
    </hostdev>

and then try to start it, and you get a bogus error message about PCI VFIO support:

# virsh  start f25x86_64
error: Failed to start domain f25x86_64
error: unsupported configuration: host doesn't support VFIO PCI interface


This is regression caused by:

commit a4a39d90ab4930750bcbcfccffdf6bb6d310b5d5
Author: Erik Skultety <eskultet>
Date:   Fri Feb 3 14:04:59 2017 +0100

    hostdev: Maintain a driver list of active mediated devices
    
    Keep track of the assigned mediated devices the same way we do it for
    the rest of hostdevs. Methods like 'Prepare', 'Update', and 'ReAttach'
    are introduced by this patch.

which introduced this check

+    if (!qemuHostdevHostSupportsPassthroughVFIO()) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("host doesn't support VFIO PCI interface"));
+        return -1;
+    }
+

that is run regardless of whether mediated devices are actually present or not.


Deleting the USB hostdev lets the guest start

Version-Release number of selected component (if applicable):
3.2.0-1.el7

How reproducible:
Always

Steps to Reproduce:
1. Create a guest with a single host USB device attached
2. Try start the geust
3.

Comment 3 Erik Skultety 2017-04-12 10:28:13 UTC
Patch proposed upstream: https://www.redhat.com/archives/libvir-list/2017-April/msg00594.html

Comment 4 Erik Skultety 2017-04-12 11:01:35 UTC
Fixed upstream by:
commit b4c2ac8d56124428d9329643a68625465094c5a7
Author:     Erik Skultety <eskultet>
AuthorDate: Wed Apr 12 10:46:35 2017 +0200
Commit:     Erik Skultety <eskultet>
CommitDate: Wed Apr 12 12:57:39 2017 +0200

    qemu: Fix mdev checking for VFIO support
    
    Commit a4a39d90 added a check that checks for VFIO support with mediated
    devices. The problem is that the hostdev preparing functions behave like
    a fallthrough if device of that specific type doesn't exist. However,
    the check for VFIO support was independent of the existence of a mdev
    device which caused the guest to fail to start with any device to be
    directly assigned if VFIO was disabled/unavailable in the kernel.
    The proposed change first ensures that it makes sense to check for VFIO
    support in the first place, and only then performs the VFIO support check
    itself.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1441291

v3.2.0-124-gb4c2ac8d5

Comment 7 Peter Krempa 2017-04-27 09:47:26 UTC
*** Bug 1446086 has been marked as a duplicate of this bug. ***

Comment 8 Pei Zhang 2017-05-11 09:34:03 UTC
I can reproduce it and verify it as following :

versions:
libvirt-3.2.0-4.el7.x86_64
qemu-kvm-rhev-2.9.0-3.el7.x86_64

steps:
1. Define a VM with an USB hostdev as folowing:
# virsh dumpxml r74 | grep hostdev -A 5
    <hostdev mode='subsystem' type='usb' managed='no'>
      <source startupPolicy='optional'>
        <vendor id='0x0951'/>
        <product id='0x1666'/>
      </source>
      <address type='usb' bus='0' port='5'/>
    </hostdev>

# virsh start r74
Domain r74 started

Guest can start successfully.
 
2. Start a VM, hotplug an USB hostdev.
# virsh list
 Id    Name                           State
----------------------------------------------------
 10    r74                            running

# cat hostdev1.xml 
<hostdev mode='subsystem' type='usb'>
  <source startupPolicy='optional'>
    <vendor id='0x0951'/>
    <product id='0x1666'/>
  </source>
</hostdev>

# virsh attach-device r74 hostdev1.xml 
Device attached successfully

3. Start guest with mdev hostdev when no VFIO support.
It should report an error.

# virsh attach-device r74 mdev.xml --config
Device attached successfully

# virsh destroy r74; virsh start r74
Domain r74 destroyed

error: Failed to start domain r74
error: unsupported configuration: Mediated host device assignment requires VFIO support

Comment 11 Pei Zhang 2017-05-12 10:39:46 UTC
As comment 8, move this bug to verified.

Comment 12 errata-xmlrpc 2017-08-02 00:05:54 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://access.redhat.com/errata/RHEA-2017:1846

Comment 13 errata-xmlrpc 2017-08-02 01:30:05 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://access.redhat.com/errata/RHEA-2017:1846


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