]> xenbits.xensource.com Git - libvirt.git/commitdiff
Reset unmanaged PCI host devices before hotplug
authorMark McLoughlin <markmc@redhat.com>
Mon, 17 Aug 2009 14:05:23 +0000 (15:05 +0100)
committerMark McLoughlin <markmc@redhat.com>
Tue, 18 Aug 2009 08:41:57 +0000 (09:41 +0100)
Right now we're only resetting managed devices before hotplug, but we
should reset them irrespective of whether they are managed.

* src/qemu_driver.c: reset all PCI hostdevs before hotplug

src/qemu_driver.c

index a638c10c706368f9f268cb71043fe3cbb684d475..06bbf2a1812a5720d9b5bf39b184b4cb8a5e2195 100644 (file)
@@ -5310,30 +5310,29 @@ static int qemudDomainAttachHostPciDevice(virConnectPtr conn,
     virDomainHostdevDefPtr hostdev = dev->data.hostdev;
     char *cmd, *reply;
     unsigned domain, bus, slot;
+    pciDevice *pci;
 
     if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0) {
         virReportOOMError(conn);
         return -1;
     }
 
-    if (hostdev->managed) {
-        pciDevice *pci = pciGetDevice(conn,
-                                      hostdev->source.subsys.u.pci.domain,
-                                      hostdev->source.subsys.u.pci.bus,
-                                      hostdev->source.subsys.u.pci.slot,
-                                      hostdev->source.subsys.u.pci.function);
-        if (!dev)
-            return -1;
-
-        if (pciDettachDevice(conn, pci) < 0 ||
-            pciResetDevice(conn, pci) < 0) {
-            pciFreeDevice(conn, pci);
-            return -1;
-        }
+    pci = pciGetDevice(conn,
+                       hostdev->source.subsys.u.pci.domain,
+                       hostdev->source.subsys.u.pci.bus,
+                       hostdev->source.subsys.u.pci.slot,
+                       hostdev->source.subsys.u.pci.function);
+    if (!dev)
+        return -1;
 
+    if ((hostdev->managed && pciDettachDevice(conn, pci) < 0) ||
+        pciResetDevice(conn, pci) < 0) {
         pciFreeDevice(conn, pci);
+        return -1;
     }
 
+    pciFreeDevice(conn, pci);
+
     if (virAsprintf(&cmd, "pci_add auto host host=%.2x:%.2x.%.1x",
                     hostdev->source.subsys.u.pci.bus,
                     hostdev->source.subsys.u.pci.slot,