From nobody Fri May 17 10:34:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1604328629; cv=none; d=zohomail.com; s=zohoarc; b=UuwUXIlpFDbEBAMzXioqKLh1LIjv/4FXZF7s1x2PmvnCMSURpobK9CcPMWR9IWJG5F4lQ5IAaJBU6rJj136QPFed+4mQi9+MadZ/6pJ9mBZlINw+JdVYCDeiAw3EGpDnY117MjVFCv2bvOcqnKi8Oopd4Xp+kLzBGCT5UuMxeg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604328629; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=9K+W28zzXL9C48llerXEFWfphofnNtxeftzieIyPceU=; b=KWzWY+ijSpzy0sb6CNEautnoinAf63YlAxhZMLl5NXKqpI1Bw4YJI/ZP9FwDrvsWSAY+hJa0IQoL+MlyV0u2IBhu9/pO2jCF2VTMeJdbHyDIV8mDl05nJtWfSwJTglejcU7eU5a7Gi7M5fQfhnDhmhhdfdbmMsDeV/nFay5ZTgI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604328629596429.1542039527435; Mon, 2 Nov 2020 06:50:29 -0800 (PST) Received: from localhost ([::1]:42884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZbAC-0002MS-6F for importer@patchew.org; Mon, 02 Nov 2020 09:50:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZb8k-0001AA-NX for qemu-devel@nongnu.org; Mon, 02 Nov 2020 09:49:00 -0500 Received: from esa1.hc3370-68.iphmx.com ([216.71.145.142]:55265) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZb8d-0007AW-GM for qemu-devel@nongnu.org; Mon, 02 Nov 2020 09:48:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1604328531; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=O4lN/nFPj6Dg10BjrFvx6wJqgawoIv0G+MT9lnkXiOs=; b=YTfz8sSCToW+7TFvOs0/3C+i+o75czUo0mrBUOQilF6dCAndebolWgVu H0XIvWvGlOs+zOaTEYFv/D5Kh8afVuz+z2yLyjJl6DwBNLhRSWblkGGgN fu8oj0AafZDa5XtOwnxKzalz9nLQuIFnvGHBCYGvqcFnG2TFp37LN6dhz M=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: vdNO5e+VUc5koX0bchd+sTWRuGYSQINfwtJEM9uq9qmSuUK96i/aPZW6Dt2D5YYO3KuFFzjWq1 qT0KDXIr8gRmuiUFDfr9ay51ia/MItpkhFzgyilsxN8kzkjlLItUUDotVDtNWTh2ihTCBw7T6e IV0CL65k6bqM8ztZ7PNprLBirCWlkn2omOEIWEN5mB6mp3A51n3YGIuBVtoC7ukvEDDcX8YmPn 7iJuxPiVWiMehZT7AH1+//4i2rFg8ArSoGzzsXu35WR74goh/OIRBGMQyDB04UON71IahamkDQ qzQ= X-SBRS: None X-MesageID: 30625389 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.77,445,1596513600"; d="scan'208";a="30625389" To: CC: Peter Maydell , Anthony PERARD Subject: [PULL 1/1] xen: rework pci_piix3_xen_ide_unplug Date: Mon, 2 Nov 2020 14:44:54 +0000 Message-ID: <20201102144454.995592-2-anthony.perard@citrix.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201102144454.995592-1-anthony.perard@citrix.com> References: <20201102144454.995592-1-anthony.perard@citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.145.142; envelope-from=anthony.perard@citrix.com; helo=esa1.hc3370-68.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 09:48:45 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Anthony PERARD From: Anthony PERARD via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This is to allow IDE disks to be unplugged when adding to QEMU via: -drive file=3D/root/disk_file,if=3Dnone,id=3Dide-disk0,format=3Draw -device ide-hd,drive=3Dide-disk0,bus=3Dide.0,unit=3D0 as the current code only works for disk added with: -drive file=3D/root/disk_file,if=3Dide,index=3D0,media=3Ddisk,format=3D= raw Since the code already have the IDE controller as `dev`, we don't need to use the legacy DriveInfo to find all the drive we want to unplug. We can simply use `blk` from the controller, as it kind of was already assume to be the same, by setting it to NULL. Signed-off-by: Anthony PERARD Acked-by: John Snow Reviewed-by: Paul Durrant Message-Id: <20201027154058.495112-1-anthony.perard@citrix.com> Signed-off-by: Anthony PERARD --- hw/ide/piix.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/hw/ide/piix.c b/hw/ide/piix.c index b402a936362b..b9860e35a5c4 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -164,30 +164,29 @@ static void pci_piix_ide_realize(PCIDevice *dev, Erro= r **errp) int pci_piix3_xen_ide_unplug(DeviceState *dev, bool aux) { PCIIDEState *pci_ide; - DriveInfo *di; int i; IDEDevice *idedev; + IDEBus *idebus; + BlockBackend *blk; =20 pci_ide =3D PCI_IDE(dev); =20 for (i =3D aux ? 1 : 0; i < 4; i++) { - di =3D drive_get_by_index(IF_IDE, i); - if (di !=3D NULL && !di->media_cd) { - BlockBackend *blk =3D blk_by_legacy_dinfo(di); - DeviceState *ds =3D blk_get_attached_dev(blk); + idebus =3D &pci_ide->bus[i / 2]; + blk =3D idebus->ifs[i % 2].blk; =20 - blk_drain(blk); - blk_flush(blk); - - if (ds) { - blk_detach_dev(blk, ds); - } - pci_ide->bus[di->bus].ifs[di->unit].blk =3D NULL; + if (blk && idebus->ifs[i % 2].drive_kind !=3D IDE_CD) { if (!(i % 2)) { - idedev =3D pci_ide->bus[di->bus].master; + idedev =3D idebus->master; } else { - idedev =3D pci_ide->bus[di->bus].slave; + idedev =3D idebus->slave; } + + blk_drain(blk); + blk_flush(blk); + + blk_detach_dev(blk, DEVICE(idedev)); + idebus->ifs[i % 2].blk =3D NULL; idedev->conf.blk =3D NULL; monitor_remove_blk(blk); blk_unref(blk); --=20 Anthony PERARD