From nobody Mon Feb 9 05:41:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569981739; cv=none; d=zoho.com; s=zohoarc; b=D1v95r9jLC6oUXhrdMwgyd7jWESJPGpHlEA0JNSM4XL++EvkH0RXKIGvPQ6QQkRm49MaJETxUbop3he1OeMHHCZHJsXee/Z13H726hHO++/a0HpKE63HP6nGgnjT7eGAHU/pCDraD62i5nGUUACF2JwIn6Zh6CUPdHwIC+PU+Hs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569981739; h=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:References:Sender:Subject:To:ARC-Authentication-Results; bh=u0/cKsicZ82bc8UUpykEz6BFD4owp9muFwqy9tLzuwk=; b=Dh8/9E5UM6/ONoe/A8hmEBx+w7i7yB2V9laCL4h/UK+UKxSiC9IQeNlBo9BCqiWml1P0plo4ubAqTDBvbxqMA4GIHprHXtNgftZefmtbeR2poGOxbR4F82Xc01TSpo4X6ZmhZ6yJcifItMlfTplD/B5lGULfhz7mr5ARNqDIMjA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail 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 1569981739768989.7620172436964; Tue, 1 Oct 2019 19:02:19 -0700 (PDT) Received: from localhost ([::1]:50506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFTy5-0006oN-Oo for importer@patchew.org; Tue, 01 Oct 2019 22:02:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46649) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFS0U-0001CP-3F for qemu-devel@nongnu.org; Tue, 01 Oct 2019 19:56:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iFS0P-0002YU-I3 for qemu-devel@nongnu.org; Tue, 01 Oct 2019 19:56:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54426) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iFS0K-0002Tc-6A; Tue, 01 Oct 2019 19:56:28 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 518F7811BF; Tue, 1 Oct 2019 23:56:27 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-165.bos.redhat.com [10.18.17.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C81A60BE0; Tue, 1 Oct 2019 23:56:25 +0000 (UTC) From: John Snow To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 4/8] scsi: Propagate unrealize() callback to scsi-hd Date: Tue, 1 Oct 2019 19:55:48 -0400 Message-Id: <20191001235552.17790-5-jsnow@redhat.com> In-Reply-To: <20191001235552.17790-1-jsnow@redhat.com> References: <20191001235552.17790-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 01 Oct 2019 23:56:27 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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: , Cc: Fam Zheng , Kevin Wolf , Thomas Huth , qemu-block@nongnu.org, "Michael S. Tsirkin" , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Arbel Moshe , Max Reitz , John Snow , "Gonglei \(Arei\)" , Sam Eiderman , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , Sam Eiderman , Laszlo Ersek , Karl Heubaum Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Sam Eiderman We will need to add LCHS removal logic to scsi-hd's unrealize() in the next commit. Signed-off-by: Sam Eiderman Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Message-id: 20190925110639.100699-5-sameid@google.com Signed-off-by: John Snow --- include/hw/scsi/scsi.h | 1 + hw/scsi/scsi-bus.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index d77a92361b..332ef602f4 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -59,6 +59,7 @@ struct SCSIRequest { typedef struct SCSIDeviceClass { DeviceClass parent_class; void (*realize)(SCSIDevice *dev, Error **errp); + void (*unrealize)(SCSIDevice *dev, Error **errp); int (*parse_cdb)(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf, void *hba_private); SCSIRequest *(*alloc_req)(SCSIDevice *s, uint32_t tag, uint32_t lun, diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index bccb7cc4c6..359d50d6d0 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -59,6 +59,14 @@ static void scsi_device_realize(SCSIDevice *s, Error **e= rrp) } } =20 +static void scsi_device_unrealize(SCSIDevice *s, Error **errp) +{ + SCSIDeviceClass *sc =3D SCSI_DEVICE_GET_CLASS(s); + if (sc->unrealize) { + sc->unrealize(s, errp); + } +} + int scsi_bus_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf, void *hba_private) { @@ -217,12 +225,20 @@ static void scsi_qdev_realize(DeviceState *qdev, Erro= r **errp) static void scsi_qdev_unrealize(DeviceState *qdev, Error **errp) { SCSIDevice *dev =3D SCSI_DEVICE(qdev); + Error *local_err =3D NULL; =20 if (dev->vmsentry) { qemu_del_vm_change_state_handler(dev->vmsentry); } =20 scsi_device_purge_requests(dev, SENSE_CODE(NO_SENSE)); + + scsi_device_unrealize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + blockdev_mark_auto_del(dev->conf.blk); } =20 --=20 2.21.0