Bug 1303160 - Connecting vfio-pci device failed, no device found with kernel > 3.10.0-229.20.1.el7.x86_64 (RHEL 7.2)
Summary: Connecting vfio-pci device failed, no device found with kernel > 3.10.0-229.2...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine
Classification: oVirt
Component: BLL.Virt
Version: 3.6.2
Hardware: x86_64
OS: Linux
urgent
urgent
Target Milestone: ovirt-3.6.7
: 3.6.7
Assignee: Martin Polednik
QA Contact: Nisim Simsolo
URL:
Whiteboard:
Depends On: 1317531
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-01-29 18:06 UTC by MNontschev
Modified: 2019-10-10 11:06 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
When assigning devices without proper hardware isolation, we were detaching even devices that should not ever be detached. We now check, before detaching any device from a host, that the device is hardware-wise suitable to be detached and does not cause other assigned devices not to be assigned. The implication is that hostdev passthrough feature now works on more machines, incl. those without full ACS support for CPU root ports.
Clone Of:
Environment:
Last Closed: 2016-07-04 12:29:42 UTC
oVirt Team: Virt
Embargoed:
rule-engine: ovirt-3.6.z+
mgoldboi: blocker+
mgoldboi: planning_ack+
michal.skrivanek: devel_ack+
mavital: testing_ack+


Attachments (Terms of Use)
lspci 229.20 kernel Z170 (1.83 KB, text/plain)
2016-02-04 21:57 UTC, MNontschev
no flags Details
lspci 327.4.5 kernel Z170 (1.83 KB, text/plain)
2016-02-04 21:58 UTC, MNontschev
no flags Details
virsh 229.20 kernel Z170 (1.06 KB, text/plain)
2016-02-04 21:58 UTC, MNontschev
no flags Details
virsh 327.4.5 kernel Z170 (1.03 KB, text/plain)
2016-02-04 21:59 UTC, MNontschev
no flags Details
vds 229.20 kernel Z170 (20.20 KB, text/plain)
2016-02-04 22:00 UTC, MNontschev
no flags Details
vds 327.4.5 kernel Z170 (20.20 KB, text/plain)
2016-02-04 22:00 UTC, MNontschev
no flags Details
vdsm.log startup VM with dvb PCI Card on Z170 kernel 327.4.5 (87.21 KB, text/plain)
2016-02-04 22:01 UTC, MNontschev
no flags Details
workaround patch (840 bytes, patch)
2016-03-30 13:33 UTC, Martin Polednik
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 56349 0 master MERGED core: Show only assignable host devices in frontend 2016-04-26 15:16:56 UTC
oVirt gerrit 56688 0 ovirt-engine-3.6 MERGED core: Show only assignable host devices in frontend 2016-05-01 08:25:28 UTC
oVirt gerrit 57506 0 ovirt-3.6 MERGED hostdev: add is_assignable flag 2016-05-17 07:02:16 UTC
oVirt gerrit 58559 0 master MERGED core: HostDevice.isAssignable true by default 2016-06-02 18:24:58 UTC
oVirt gerrit 58564 0 ovirt-engine-4.0 MERGED core: HostDevice.isAssignable true by default 2016-06-03 10:04:46 UTC
oVirt gerrit 58583 0 ovirt-engine-3.6 MERGED core: HostDevice.isAssignable true by default 2016-06-03 10:06:01 UTC
oVirt gerrit 58601 0 ovirt-engine-3.6.7 MERGED core: HostDevice.isAssignable true by default 2016-06-03 10:21:10 UTC

Description MNontschev 2016-01-29 18:06:31 UTC
After upgrading to CentOS 7.2 (from 7.1 installation) starting of VMs with attached DVB PCI devices failes.

MSG:
VM vdr is down with error. Exit message: Verbinden von PCI-Gerät '0000:00:1c.0' mit vfio-pci fehlgeschlagen: Kein passendes Gerät gefunden.

This is partially german and means:
VM vdr is down with error. Exit message: Connecting of PCI-Device '0000:00:1c.0' with vfio-pci failed: no device found

Booting kernel 3.10.0-229.20.1.el7.x86_64 without any other changes works.

Tested Kernel which trigger this Bug:
3.10.0-327.3.1.el7.x86_64
3.10.0-327.4.4.el7.x86_64
3.10.0-327.4.5.el7.x86_64

This Bug shows on two different machines. The first with Desktop chipset Z170T, the other is a Xeon with C226. Both with different DVB cards. The listed host devices, IOMMU numbers etc. are listed correctly, only booting the VM failes.

I dont know which component is responsible for the 'not finding'.

Comment 1 Martin Polednik 2016-02-03 10:08:17 UTC
Please supply outputs of following commands on both kernels:

- lspci
- virsh -r nodedev-list
- vdsClient -s 0 hostdevListByCaps

and /etc/vdsm/vdsm.log containing the information about VM start (the XML and libvirt error) from new kernel.

Comment 2 MNontschev 2016-02-04 21:57:42 UTC
Created attachment 1121218 [details]
lspci 229.20 kernel Z170

Comment 3 MNontschev 2016-02-04 21:58:23 UTC
Created attachment 1121219 [details]
lspci 327.4.5 kernel Z170

Comment 4 MNontschev 2016-02-04 21:58:57 UTC
Created attachment 1121221 [details]
virsh 229.20 kernel Z170

Comment 5 MNontschev 2016-02-04 21:59:27 UTC
Created attachment 1121223 [details]
virsh 327.4.5 kernel Z170

Comment 6 MNontschev 2016-02-04 22:00:01 UTC
Created attachment 1121224 [details]
vds 229.20 kernel Z170

Comment 7 MNontschev 2016-02-04 22:00:36 UTC
Created attachment 1121225 [details]
vds 327.4.5 kernel Z170

Comment 8 MNontschev 2016-02-04 22:01:37 UTC
Created attachment 1121226 [details]
vdsm.log startup VM with dvb PCI Card on Z170 kernel 327.4.5

Comment 9 MNontschev 2016-02-04 22:05:32 UTC
I tested some other devices an amd graphics card works with 229 kernel and does not with 327. USB devices are working on both kernel.

maybe this helps

Comment 10 Martin Polednik 2016-02-08 09:04:29 UTC
Part of the issue is the fact that we assign the whole IOMMU group to a VM incl. root port/pci/pcie bridges. I'm not sure how that worked in the first scenario, but there could have been updates to Z170 isolation quirks.

Our scenario will currently look like this:
02:00.0 Multimedia controller: Digital Devices GmbH Cine V7 (iommu group 6)
 -> (assuming it's the device) shares group with 
00:1c.0 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #8 (rev f1)
(iommu group 6)
 -> both will be detached and assigned to a VM

Alex, do you know of some notable change between those kernels? Why did the assignment with root port included work with older kernel?

Comment 11 Alex Williamson 2016-02-08 17:34:29 UTC
(In reply to Martin Polednik from comment #10)
> Part of the issue is the fact that we assign the whole IOMMU group to a VM
> incl. root port/pci/pcie bridges. I'm not sure how that worked in the first
> scenario, but there could have been updates to Z170 isolation quirks.
> 
> Our scenario will currently look like this:
> 02:00.0 Multimedia controller: Digital Devices GmbH Cine V7 (iommu group 6)
>  -> (assuming it's the device) shares group with 
> 00:1c.0 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port
> #8 (rev f1)
> (iommu group 6)
>  -> both will be detached and assigned to a VM
> 
> Alex, do you know of some notable change between those kernels? Why did the
> assignment with root port included work with older kernel?

It was a bug in older kernels that has since been fixed.  See:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=7c2e211f3c95b91912a92a8c6736343690042e2e

The vfio-pci driver has never supported anything other than type 0 header devices (ie. endpoints).  Binding bridges, including root ports, to vfio-pci can disconnect management drivers, hotplug drivers, and sometimes leaves the bridge in a disabled state where devices behind the bridge don't work.  As the code shows, this was always the intention to prevent binding these devices, but a bug allowed it anyway.

Comment 12 Martin Polednik 2016-02-09 10:00:55 UTC
current workaround: Use the lower kernel version for the time being OR try to use a group without bridge/root port in it.

Comment 13 Red Hat Bugzilla Rules Engine 2016-02-09 10:00:58 UTC
Bug tickets must have version flags set prior to targeting them to a release. Please ask maintainer to set the correct version flags and only then set the target milestone.

Comment 14 MNontschev 2016-02-10 17:54:45 UTC
In my cases i can not avoid bridge/root port. This means RHEL 7.1 kernel. I suggest to remove RHEL 7.2 from the supported list of ovirt 3.6 or at least a severe warning in vfio-pci cases.

Comment 18 Martin Polednik 2016-03-30 09:02:36 UTC
Possible workaround, must be applied on each hypervisor targeted for VFIO assignment where the bug occurs:

# script start
cat << EOF > workaround.patch
--- hostdev.py  2016-03-16 11:18:49.928014050 +0100
+++ /usr/share/vdsm/hostdev.py  2016-03-16 11:17:34.000000000 +0100
@@ -33,6 +33,15 @@
    pass


+def _pci_header_type(device_name):
+    with open('/sys/bus/pci/devices/{0}/config'.format(
+            name_to_pci_path(device_name)), 'rb') as f:
+        f.seek(0x0e)
+        header_type = ord(f.read(1)) & 0x7f
+
+    return header_type
+
+
def name_to_pci_path(device_name):
    return device_name[4:].replace('_', '.').replace('.', ':', 2)

@@ -193,7 +202,7 @@
    libvirt_device, device_params = _get_device_ref_and_params(device_name)
    capability = CAPABILITY_TO_XML_ATTR[device_params['capability']]

-    if capability == 'pci':
+    if capability == 'pci' and not _pci_header_type(device_name):
        try:
            iommu_group = device_params['iommu_group']
        except KeyError:
@@ -212,7 +221,7 @@
    libvirt_device, device_params = _get_device_ref_and_params(device_name)
    capability = CAPABILITY_TO_XML_ATTR[device_params['capability']]

-    if capability == 'pci':
+    if capability == 'pci' and not _pci_header_type(device_name):
        try:
            iommu_group = device_params['iommu_group']
        except KeyError:
EOF
patch /usr/share/vdsm/hostdev.py workaround.patch
service vdsmd restart
# script end

Comment 20 Martin Polednik 2016-03-30 13:33:08 UTC
Created attachment 1141755 [details]
workaround patch

Also newer version of the patch that should work 3.6.0 through 3.6.3. Submitted as attachment due to possible malformation caused by copy-pasting patch around.

Comment 21 MNontschev 2016-04-18 16:16:32 UTC
I tested the patch from comment #18

my platform: oVirt 3.6.4 , libvirt-1.2.17-13.el7_2.4, vdsm-4.17.23.2-1.el7

without patch kernel
3.10.0-229.20.1.el7.x86_64 -> works
3.10.0-327.13.1.el7.x86_64 -> failed
with patch
3.10.0-229.20.1.el7.x86_64 -> works
3.10.0-327.13.1.el7.x86_64 -> works

thx

Comment 22 Nisim Simsolo 2016-05-16 09:14:38 UTC
Reassigned, workaround is missing.
rhevm-3.6.6.2-0.1.el6
qemu-kvm-rhev-2.3.0-31.el7_2.11.x86_64
vdsm-4.17.28-0.el7ev.noarch
libvirt-client-1.2.17-13.el7_2.4.x86_64

Comment 23 Red Hat Bugzilla Rules Engine 2016-05-16 09:14:43 UTC
Target release should be placed once a package build is known to fix a issue. Since this bug is not modified, the target version has been reset. Please use target milestone to plan a fix for a oVirt release.

Comment 24 Michal Skrivanek 2016-05-16 09:22:38 UTC
would you provide more details? you shouldn't be able to assign a device which is not an end node anymore. Are you saying you still can?

Comment 26 MNontschev 2016-05-25 19:41:55 UTC
When i add the dvb device it automatically add's the pcie root port (same iommu, grey listed). This works as before and is expected.

This bug describes the problem that it could not find pci devices during startup (after kernel update). This happens with VGA Adapter, NIC, DVB device ...

I think the problems mentioned in comment #10 and comment #11 are not related with this bug. The root ports are added through the web page, and yes it still works.

Comment 27 MNontschev 2016-05-31 17:51:41 UTC
The oVirt 3.6.6 release notes lists this Bug as fixed. This is NOT true, but the patch from comment #18 still fixes the problem.

Comment 28 Michal Skrivanek 2016-06-01 10:06:05 UTC
(In reply to MNontschev from comment #27)
> The oVirt 3.6.6 release notes lists this Bug as fixed. This is NOT true, but
> the patch from comment #18 still fixes the problem.

yes, it was later found out that one patch is not really in the build, and reopened and retargeted to 3.6.7 on 2016-05-16 13:00:01 CEST
Please try in 3.6.7

Comment 29 Nisim Simsolo 2016-06-02 15:21:53 UTC
Verified, the patch was merged and it's possible to attach host device to VM. (verified with GPU, PCI and USB devices).

Verification build:
rhevm-3.6.7.1-0.1.el6.noarch
qemu-kvm-rhev-2.3.0-31.el7_2.12.x86_64
sanlock-3.2.4-2.el7_2.x86_64
vdsm-4.17.28-0.el7ev.noarch -> upgraded to vdsm-4.17.29-0.el7ev.noarch
libvirt-client-1.2.17-13.el7_2.4.x86_64

Also, an upgrade of VDSM build from vdsm-4.17.28-0.el7ev.noarch to vdsm-4.17.29-0.el7ev.noarch was used in order to see if bug 1341299 is affecting this bug.  

Verification scenario: 
1. Use host with vdsm-4.17.28-0.el7ev: Browse webadmin -> virtual machines tab -> select VM -> host devices tab -> add device
2. list is empty (bug 1341299)
3. upgrade VDSM to vdsm-4.17.29-0.el7ev
4. Navigate to hosts tab and refresh host capabilities
5. Navigate to virtual machines tab -> select VM -> host devices tab -> add device
6. Verify devices are now listed.
7. Attach GPU, PCI and USB devices to VM.
8. Run VM and verify devices are attached properly.

Comment 30 Nisim Simsolo 2016-06-02 16:00:40 UTC
Also verified that host devices is_assignable == True under hostdevListByCaps:
vdsClient -s 0 hostdevListByCaps


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