From patchwork Mon Aug 3 14:33:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 503198 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6CE7E140E32 for ; Tue, 4 Aug 2015 00:35:41 +1000 (AEST) Received: from localhost ([::1]:59405 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMGq3-0001Xi-8b for incoming@patchwork.ozlabs.org; Mon, 03 Aug 2015 10:35:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMGph-0001B0-1K for qemu-devel@nongnu.org; Mon, 03 Aug 2015 10:35:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZMGpZ-0001P3-L6 for qemu-devel@nongnu.org; Mon, 03 Aug 2015 10:35:16 -0400 Received: from smtp.citrix.com ([66.165.176.89]:15560) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMGpZ-0001Ow-Gt for qemu-devel@nongnu.org; Mon, 03 Aug 2015 10:35:09 -0400 X-IronPort-AV: E=Sophos;i="5.15,602,1432598400"; d="scan'208";a="287342796" From: Stefano Stabellini To: Date: Mon, 3 Aug 2015 15:33:45 +0100 Message-ID: <1438612425-27068-1-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-DLP: MIA2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.89 Cc: xen-devel@lists.xensource.com, qemu-devel@nongnu.org, Stefano Stabellini Subject: [Qemu-devel] [PULL for-2.4 1/1] Fix release_drive on unplugged devices (pci_piix3_xen_ide_unplug) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 adb6649..5a26c86 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -169,6 +169,7 @@ int pci_piix3_xen_ide_unplug(DeviceState *dev) PCIIDEState *pci_ide; DriveInfo *di; int i; + IDEDevice *idedev; pci_ide = PCI_IDE(dev); @@ -181,6 +182,12 @@ int pci_piix3_xen_ide_unplug(DeviceState *dev) blk_detach_dev(blk, ds); } pci_ide->bus[di->bus].ifs[di->unit].blk = NULL; + if (!(i % 2)) { + idedev = pci_ide->bus[di->bus].master; + } else { + idedev = pci_ide->bus[di->bus].slave; + } + idedev->conf.blk = NULL; blk_unref(blk); } }