]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Fix mdev checking for VFIO support
authorErik Skultety <eskultet@redhat.com>
Wed, 12 Apr 2017 08:46:35 +0000 (10:46 +0200)
committerCole Robinson <crobinso@redhat.com>
Wed, 10 May 2017 19:30:38 +0000 (15:30 -0400)
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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
(cherry picked from commit b4c2ac8d56124428d9329643a68625465094c5a7)

src/qemu/qemu_hostdev.c

index 685bf5b59f67152b08e543d5021690ba7af0261e..73d26f4c637ad04a2f83c2dd0a2c604d9d50cf01 100644 (file)
@@ -330,11 +330,20 @@ qemuHostdevPrepareMediatedDevices(virQEMUDriverPtr driver,
                                   int nhostdevs)
 {
     virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
+    bool supportsVFIO = qemuHostdevHostSupportsPassthroughVFIO();
+    size_t i;
 
-    if (!qemuHostdevHostSupportsPassthroughVFIO()) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("host doesn't support VFIO PCI interface"));
-        return -1;
+    for (i = 0; i < nhostdevs; i++) {
+        if (hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+            hostdevs[i]->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV) {
+            if (!supportsVFIO) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("Mediated host device assignment requires "
+                                 "VFIO support"));
+                return -1;
+            }
+            break;
+        }
     }
 
     return virHostdevPrepareMediatedDevices(hostdev_mgr, QEMU_DRIVER_NAME,