]> xenbits.xensource.com Git - qemu-upstream-4.3-testing.git/commitdiff
Fix release_drive on unplugged devices (pci_piix3_xen_ide_unplug)
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>
Mon, 3 Aug 2015 14:07:02 +0000 (14:07 +0000)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Mon, 3 Aug 2015 14:18:35 +0000 (14:18 +0000)
pci_piix3_xen_ide_unplug should completely unhook the unplugged
IDEDevice from the corresponding BlockBackend, otherwise the next call
to release_drive will try to detach the drive again.

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
hw/ide/piix.c

index 34b47a0b12f1c2b32b6e8ccf9d3b441caddb888a..a8384da06e3cebc10070e062f90b86094a9705ff 100644 (file)
@@ -172,6 +172,7 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev)
     PCIIDEState *pci_ide;
     DriveInfo *di;
     int i;
+    IDEDevice *idedev;
 
     pci_dev = DO_UPCAST(PCIDevice, qdev, dev);
     pci_ide = DO_UPCAST(PCIIDEState, dev, pci_dev);
@@ -185,6 +186,12 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev)
             }
             bdrv_close(di->bdrv);
             pci_ide->bus[di->bus].ifs[di->unit].bs = NULL;
+            if (!(i % 2)) {
+                idedev = pci_ide->bus[di->bus].master;
+            } else {
+                idedev = pci_ide->bus[di->bus].slave;
+            }
+            idedev->conf.bs = NULL;
             drive_put_ref(di);
         }
     }