From 138906105dd47b9dc6b1e5010e81fc606983dd75 Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Mon, 3 Aug 2015 14:07:02 +0000 Subject: [PATCH] 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 --- hw/ide/piix.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 3dbfc12a7..b1802defc 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -170,6 +170,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); @@ -183,6 +184,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); } } -- 2.39.5