From patchwork Wed Sep 25 11:06:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)\" via" X-Patchwork-Id: 11160445 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0527C14DB for ; Wed, 25 Sep 2019 11:17:32 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CCAFB214D9 for ; Wed, 25 Sep 2019 11:17:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="itCwXwjF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CCAFB214D9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=nongnu.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD5IY-0001hm-K7 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 07:17:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44859) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3U0qLXQYKCgg0iumqlowwotm.kwuymu2-lm3mtvwvov2.wzo@flex--sameid.bounces.google.com>) id 1iD58R-000831-1z for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3U0qLXQYKCgg0iumqlowwotm.kwuymu2-lm3mtvwvov2.wzo@flex--sameid.bounces.google.com>) id 1iD58P-0004Tu-QA for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:02 -0400 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]:55102) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3U0qLXQYKCgg0iumqlowwotm.kwuymu2-lm3mtvwvov2.wzo@flex--sameid.bounces.google.com>) id 1iD58P-0004Sv-FM for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:01 -0400 Received: by mail-wr1-x44a.google.com with SMTP id z1so2172327wrw.21 for ; Wed, 25 Sep 2019 04:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=7sLdv/qenkIM9QFawRYLGJz07khj1BZO3MCkag3rnZQ=; b=itCwXwjF4HKp1ICF6u3BN3A5+ZtwlWC6Eq2uxgit+woEDyX2oSLgiiK4vxSEDQslOI aXV3EkzwgzVG8QY8YVYqfbJoanaukt8YsfJnzmdrz2Ynm11oDdynnLgGyL4cVDuq2JQc b8fQfcsYto11MzGaezOWLcf46EbxRkg74VPLv0Imxig+fyvNyz6w80igSHKwU1Xx2yit D50lPa9P9K81uayNbNiyB7VZqClZhy3GLdmCHvXo4ZHOyF1EQrOxagMdy7M8AG+nGRLs UFiFczzfkAQu+qUePLob1YEV7yKM1UVhS4PU1am/rVQK2d/cq3x6wsOsKOkLjzEV4fX1 wKkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=7sLdv/qenkIM9QFawRYLGJz07khj1BZO3MCkag3rnZQ=; b=Pwv8yCfxv7jAjBCNyVvKdoCbkk6CUum72gCeYRUwQke8bhLb06K+nLwWwsdlRkX2hT 0MsY72fdtYIxgmwQiUZ3P2HKocX7u4G7yo6XqCE5nAm2TqNNR2HUNPVH+nv8hLH84KlZ p/fl+HNP2lfeim5XXqK+gKjkLy2e4R1CK0XUsCoXsxtC6RY0HmkjHkFlY+gX8zjJJo+T kV8XmO4TjzznenULOJCV7/79HpOAUIfUCHpx7Lf3lDxPwYUU+RBBnccQfVweyng0obfz Ty3R87FotaQEJ+/3DsbvqpHXZAcCsX9NE1Ds6LVNhNmfY8ByLfr9vKWZ8jS3j9NpNN9J FFuQ== X-Gm-Message-State: APjAAAVwwGv/qxAqWu0z44axyBGGnNqXFdnPCzZezqxjmxocSJZxJAZJ y8Scf3iFc11coBXd/ylSXepxtr86ep0re2dKv8uoNjzw+VsUOqKSsaAgYSD3j3PO0pE2vjHZ+Kn Bi9wedbHuRXlAY1mDrYFXriVkDsDPhUK1fxylm+az2XCrvJ4R/swvVRz9oWvz X-Google-Smtp-Source: APXvYqwC2WZJOZmBBYlq0W2s0Z/KfuBqPF7r3H4ghdG6zJOxTM/8lCvcoKyM6HmFJYuBGAMAsGAOJ4UArDA= X-Received: by 2002:adf:ed88:: with SMTP id c8mr9195400wro.329.1569409619883; Wed, 25 Sep 2019 04:06:59 -0700 (PDT) Date: Wed, 25 Sep 2019 14:06:35 +0300 In-Reply-To: <20190925110639.100699-1-sameid@google.com> Message-Id: <20190925110639.100699-5-sameid@google.com> Mime-Version: 1.0 References: <20190925110639.100699-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.351.gc4317032e6-goog Subject: [PATCH v7 4/8] scsi: Propagate unrealize() callback to scsi-hd To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::44a 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: kwolf@redhat.com, qemu-block@nongnu.org, arbel.moshe@oracle.com, seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Reply-to: Sam Eiderman X-Patchwork-Original-From: Sam Eiderman via From: "Zhijian Li (Fujitsu)\" via" 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 Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/scsi-bus.c | 16 ++++++++++++++++ include/hw/scsi/scsi.h | 1 + 2 files changed, 17 insertions(+) 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 **errp) } } +static void scsi_device_unrealize(SCSIDevice *s, Error **errp) +{ + SCSIDeviceClass *sc = 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, Error **errp) static void scsi_qdev_unrealize(DeviceState *qdev, Error **errp) { SCSIDevice *dev = SCSI_DEVICE(qdev); + Error *local_err = NULL; if (dev->vmsentry) { qemu_del_vm_change_state_handler(dev->vmsentry); } 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); } 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,