From patchwork Tue Feb 18 14:25:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 24854 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E9439202B2 for ; Tue, 18 Feb 2014 14:26:47 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id fa1sf41050487pad.4 for ; Tue, 18 Feb 2014 06:26:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:in-reply-to:message-id :references:user-agent:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type; bh=+6GX4RlvzjOX1xvk3BOqPJVh/Vl3y6w75HLvHdklSSQ=; b=QGwRdSPt36UV7j3ldH8kDrJwJ05ezUONMWk1x2cDUYSrvZik9ch6whEZlUFOwZHxGJ mFmDsSMSIDRFGJ6yTDCDkjvsNO8e4PyJMlnjFzmcAKN0dOeZQevBEmU/2Fl4zHAltkW9 aM3XikdE2hNhTK8oiL5qKyvrwinoioJaaTK3D/iDx25rVaql0ccEa6bw6V+YIkkyzxAU 0g6d4v4hjCSihuBEJ20SjHYLZEbnEbA+48k8am6Wz/kGrXw6Ta7TQlx0tfmSwZ2K9gkh 7jMKub3W2llhCeZgpewhZknYdeozMCVsQY+k6s5wPQag4KPAkFQO4AUY3rZOif/xJCU8 OMEg== X-Gm-Message-State: ALoCoQmBjshpqHlst2zAUjOWsZrs1Qj3KD99fDtapQIaYT9aej1/3eGH2D+Qq8ocQrzQen3ZgNWX X-Received: by 10.66.66.109 with SMTP id e13mr12767719pat.1.1392733607097; Tue, 18 Feb 2014 06:26:47 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.48.38 with SMTP id n35ls1374063qga.68.gmail; Tue, 18 Feb 2014 06:26:46 -0800 (PST) X-Received: by 10.220.112.75 with SMTP id v11mr56350vcp.74.1392733606800; Tue, 18 Feb 2014 06:26:46 -0800 (PST) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id ke3si5554861veb.27.2014.02.18.06.26.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 06:26:46 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id lf12so13353450vcb.3 for ; Tue, 18 Feb 2014 06:26:46 -0800 (PST) X-Received: by 10.52.164.39 with SMTP id yn7mr14760188vdb.25.1392733606717; Tue, 18 Feb 2014 06:26:46 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp220327vcz; Tue, 18 Feb 2014 06:26:41 -0800 (PST) X-Received: by 10.229.119.73 with SMTP id y9mr2545474qcq.18.1392733601398; Tue, 18 Feb 2014 06:26:41 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id bf1si4543696qcb.107.2014.02.18.06.26.41 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 18 Feb 2014 06:26:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:49556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFldA-0006IW-QO for patch@linaro.org; Tue, 18 Feb 2014 09:26:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFlcc-0005ic-7F for qemu-devel@nongnu.org; Tue, 18 Feb 2014 09:26:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFlcX-0004bl-Dc for qemu-devel@nongnu.org; Tue, 18 Feb 2014 09:26:06 -0500 Received: from smtp.citrix.com ([66.165.176.89]:20194) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFlcX-0004bV-7Y for qemu-devel@nongnu.org; Tue, 18 Feb 2014 09:26:01 -0500 X-IronPort-AV: E=Sophos;i="4.97,502,1389744000"; d="scan'208";a="103488757" Received: from accessns.citrite.net (HELO FTLPEX01CL01.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 18 Feb 2014 14:25:58 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.2.342.4; Tue, 18 Feb 2014 09:25:58 -0500 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1WFlcS-00040D-Gt; Tue, 18 Feb 2014 14:25:56 +0000 Date: Tue, 18 Feb 2014 14:25:52 +0000 From: Stefano Stabellini X-X-Sender: sstabellini@kaball.uk.xensource.com To: Paolo Bonzini In-Reply-To: <53035BD8.6050805@redhat.com> Message-ID: References: <1392050814-31814-1-git-send-email-mst@redhat.com> <530351B4.1010402@redhat.com> <53035BD8.6050805@redhat.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) 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: Peter Maydell , xen-devel@lists.xensource.com, "Michael S. Tsirkin" , Stefano Stabellini , QEMU Developers , armbru@redhat.com, Anthony Liguori , Anthony.Perard@citrix.com Subject: Re: [Qemu-devel] [PULL 00/20] acpi,pc,pci fixes and enhancements 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stefano.stabellini@eu.citrix.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 On Tue, 18 Feb 2014, Paolo Bonzini wrote: > Il 18/02/2014 13:45, Stefano Stabellini ha scritto: > > Disk unplug: hw/ide/piix.c:pci_piix3_xen_ide_unplug (see the beginning > > of the email :-P). > > It is called by hw/xen/xen_platform.c:platform_fixed_ioport_writew, in > > response to the guest writing to a magic ioport specifically to unplug > > the emulated disk. > > With this patch after the guest boots I can still access both xvda and > > sda for the same disk, leading to fs corruptions. > > Ok, the last paragraph is what I was missing. > > So this is dc->unplug for the PIIX3 IDE device. Because PCI declares a > hotplug handler, dc->unplug is not called anymore. > > But unlike other dc->unplug callbacks, pci_piix3_xen_ide_unplug doesn't free > the device, it just drops the disks underneath. I think the simplest solution > is to _not_ make it a dc->unplug callback at all, and call > pci_piix3_xen_ide_unplug from unplug_disks instead of qdev_unplug. > qdev_unplug means "ask guest to start unplug", which is not what Xen wants to > do here. Yes, you are right, pci_piix3_xen_ide_unplug is not called anymore. Calling it directly from unplug_disks fixes the issue: --- Call pci_piix3_xen_ide_unplug from unplug_disks Signed-off-by: Stefano Stabellini diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 0eda301..40757eb 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -167,7 +167,7 @@ static int pci_piix_ide_initfn(PCIDevice *dev) return 0; } -static int pci_piix3_xen_ide_unplug(DeviceState *dev) +int pci_piix3_xen_ide_unplug(DeviceState *dev) { PCIIDEState *pci_ide; DriveInfo *di; @@ -266,7 +266,6 @@ static void piix3_ide_xen_class_init(ObjectClass *klass, void *data) k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1; k->class_id = PCI_CLASS_STORAGE_IDE; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); - dc->unplug = pci_piix3_xen_ide_unplug; } static const TypeInfo piix3_ide_xen_info = { diff --git a/hw/xen/xen_platform.c b/hw/xen/xen_platform.c index 70875e4..1d9d0e9 100644 --- a/hw/xen/xen_platform.c +++ b/hw/xen/xen_platform.c @@ -27,6 +27,7 @@ #include "hw/hw.h" #include "hw/i386/pc.h" +#include "hw/ide.h" #include "hw/pci/pci.h" #include "hw/irq.h" #include "hw/xen/xen_common.h" @@ -110,7 +111,7 @@ static void unplug_disks(PCIBus *b, PCIDevice *d, void *o) if (pci_get_word(d->config + PCI_CLASS_DEVICE) == PCI_CLASS_STORAGE_IDE && strcmp(d->name, "xen-pci-passthrough") != 0) { - qdev_unplug(DEVICE(d), NULL); + pci_piix3_xen_ide_unplug(DEVICE(d)); } } diff --git a/include/hw/ide.h b/include/hw/ide.h index 507e6d3..bc8bd32 100644 --- a/include/hw/ide.h +++ b/include/hw/ide.h @@ -17,6 +17,7 @@ void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table, PCIDevice *pci_piix3_xen_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn); PCIDevice *pci_piix3_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn); PCIDevice *pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn); +int pci_piix3_xen_ide_unplug(DeviceState *dev); void vt82c686b_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn); /* ide-mmio.c */