From: Stefano Stabellini Date: Mon, 3 Aug 2015 14:07:02 +0000 (+0000) Subject: Fix release_drive on unplugged devices (pci_piix3_xen_ide_unplug) X-Git-Tag: qemu-xen-4.4.3^0 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=0fc147387f0b683d2dfefec7b1af569f17b72e9c;p=qemu-xen.git Fix release_drive on unplugged devices (pci_piix3_xen_ide_unplug) 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 Signed-off-by: Stefano Stabellini --- diff --git a/hw/ide/piix.c b/hw/ide/piix.c index c043a8de44..15729f0f71 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -172,6 +172,7 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev) PCIIDEState *pci_ide; DriveInfo *di; int i; + IDEDevice *idedev; pci_ide = PCI_IDE(dev); @@ -184,6 +185,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); } }