]> xenbits.xensource.com Git - libvirt.git/commitdiff
Reset PCI host devices after hot-unplug
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)
When we hot-unplug a PCI host device from a guest, we should reset it.

Both managed and unmanaged devices should be reset, but only managed
devices should be re-attached.

* src/qemu_driver.c: reset devices in qemudDomainDetachHostPciDevice()

src/qemu_driver.c

index 06bbf2a1812a5720d9b5bf39b184b4cb8a5e2195..187497f953d5c44716a30f951bcdefe8f24cc353 100644 (file)
@@ -5780,6 +5780,7 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn,
     virDomainHostdevDefPtr detach;
     char *cmd, *reply;
     int i, ret;
+    pciDevice *pci;
 
     for (i = 0 ; i < vm->def->nhostdevs ; i++) {
         unsigned domain   = vm->def->hostdevs[i]->source.subsys.u.pci.domain;
@@ -5848,16 +5849,19 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn,
 
     ret = 0;
 
-    if (detach->managed) {
-        pciDevice *pci = pciGetDevice(conn,
-                                      detach->source.subsys.u.pci.domain,
-                                      detach->source.subsys.u.pci.bus,
-                                      detach->source.subsys.u.pci.slot,
-                                      detach->source.subsys.u.pci.function);
-        if (!pci || pciReAttachDevice(conn, pci) < 0)
+    pci = pciGetDevice(conn,
+                       detach->source.subsys.u.pci.domain,
+                       detach->source.subsys.u.pci.bus,
+                       detach->source.subsys.u.pci.slot,
+                       detach->source.subsys.u.pci.function);
+    if (!pci)
+        ret = -1;
+    else {
+        if (pciResetDevice(conn, pci) < 0)
+            ret = -1;
+        if (detach->managed && pciReAttachDevice(conn, pci) < 0)
             ret = -1;
-        if (pci)
-            pciFreeDevice(conn, pci);
+        pciFreeDevice(conn, pci);
     }
 
     if (i != --vm->def->nhostdevs)