]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
qemu: don't reset PCI devices being assigned with VFIO
authorLaine Stump <laine@laine.org>
Mon, 24 Jun 2013 16:00:51 +0000 (12:00 -0400)
committerLaine Stump <laine@laine.org>
Tue, 25 Jun 2013 03:07:07 +0000 (23:07 -0400)
I just learned that VFIO resets PCI devices when they are assigned to
guests / returned to the host, so it is redundant for libvirt to reset
the devices. This patch inhibits calling virPCIDeviceReset to devices
that will be/were assigned using VFIO.

src/qemu/qemu_hostdev.c
src/qemu/qemu_hotplug.c

index 7a9e6eba05c46a3af34da8d22c001827e6f25851..c507c311104890d6a4218233ea59ca0133223942 100644 (file)
@@ -548,6 +548,8 @@ int qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver,
      * can safely reset them */
     for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
         virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
+        if (STREQ_NULLABLE(virPCIDeviceGetStubDriver(dev), "vfio-pci"))
+            continue;
         if (virPCIDeviceReset(dev, driver->activePciHostdevs,
                               driver->inactivePciHostdevs) < 0)
             goto reattachdevs;
@@ -1114,6 +1116,8 @@ void qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
 
     for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
         virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
+        if (STREQ_NULLABLE(virPCIDeviceGetStubDriver(dev), "vfio-pci"))
+            continue;
         if (virPCIDeviceReset(dev, driver->activePciHostdevs,
                               driver->inactivePciHostdevs) < 0) {
             virErrorPtr err = virGetLastError();
index 18f5fa530db1cdb3bbc0c7c60e1cbae16690edf9..46875ad6c99c02d584cadac6914cb6f5ea677289 100644 (file)
@@ -2528,8 +2528,9 @@ qemuDomainDetachHostPciDevice(virQEMUDriverPtr driver,
     if (pci) {
         activePci = virPCIDeviceListSteal(driver->activePciHostdevs, pci);
         if (activePci &&
-            virPCIDeviceReset(activePci, driver->activePciHostdevs,
-                              driver->inactivePciHostdevs) == 0) {
+            (subsys->u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO ||
+             virPCIDeviceReset(activePci, driver->activePciHostdevs,
+                               driver->inactivePciHostdevs) == 0)) {
             qemuReattachPciDevice(activePci, driver);
             ret = 0;
         } else {