]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_hotplug: Drop PCI backend check in qemuDomainAttachHostPCIDevice()
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 24 Apr 2023 07:53:33 +0000 (09:53 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 25 Apr 2023 10:36:30 +0000 (12:36 +0200)
There is no way the qemuDomainAttachHostPCIDevice() function can
be called over a hostdev with PCI backend other than VFIO. And
even if it were, then the check is written so poorly that it lets
some types through (e.g. KVM) only to let
qemuBuildPCIHostdevDevProps() called afterwards fail properly.

Drop this check and rely on qemuDomainPrepareHostdevPCI() (and
worst case scenario even qemuBuildPCIHostdevDevProps()) to report
the proper error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_hotplug.c

index 9cefac9001895bbbdd979b6383577805befee3c9..ba49bb76c5c8752e77cf5e5e3c6345b1c79c5d49 100644 (file)
@@ -1483,7 +1483,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriver *driver,
     bool teardownlabel = false;
     bool teardowndevice = false;
     bool teardownmemlock = false;
-    int backend;
     g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
     unsigned int flags = 0;
 
@@ -1495,32 +1494,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriver *driver,
                                      &hostdev, 1, priv->qemuCaps, flags) < 0)
         return -1;
 
-    /* this could have been changed by qemuDomainPrepareHostdevPCI() */
-    backend = hostdev->source.subsys.u.pci.backend;
-
-    switch (backend) {
-    case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO:
-        if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("VFIO PCI device assignment is not "
-                             "supported by this version of qemu"));
-            goto error;
-        }
-        break;
-
-    case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT:
-    case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM:
-        break;
-
-    case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN:
-    case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("QEMU does not support device assignment mode '%1$s'"),
-                       virDomainHostdevSubsysPCIBackendTypeToString(backend));
-        goto error;
-        break;
-    }
-
     if (qemuDomainAdjustMaxMemLockHostdev(vm, hostdev) < 0)
         goto error;
     teardownmemlock = true;
@@ -1534,8 +1507,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriver *driver,
 
     if (qemuSecuritySetHostdevLabel(driver, vm, hostdev) < 0)
         goto error;
-    if (backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO)
-        teardownlabel = true;
+    teardownlabel = true;
 
     qemuAssignDeviceHostdevAlias(vm->def, &info->alias, -1);