From patchwork Tue Sep 21 15:22:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 65331 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C1020B70A3 for ; Wed, 22 Sep 2010 02:06:29 +1000 (EST) Received: from localhost ([127.0.0.1]:51916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oy5MM-0003kg-UL for incoming@patchwork.ozlabs.org; Tue, 21 Sep 2010 12:06:23 -0400 Received: from [140.186.70.92] (port=49284 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oy4fX-0008AL-L7 for qemu-devel@nongnu.org; Tue, 21 Sep 2010 11:22:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oy4fU-0005w1-09 for qemu-devel@nongnu.org; Tue, 21 Sep 2010 11:22:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65306) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oy4fT-0005vh-Q1 for qemu-devel@nongnu.org; Tue, 21 Sep 2010 11:22:03 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8LFM1X9032022 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 21 Sep 2010 11:22:01 -0400 Received: from dhcp-5-188.str.redhat.com (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8LFLZnu016774; Tue, 21 Sep 2010 11:22:00 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Tue, 21 Sep 2010 17:22:00 +0200 Message-Id: <1285082522-24407-19-git-send-email-kwolf@redhat.com> In-Reply-To: <1285082522-24407-1-git-send-email-kwolf@redhat.com> References: <1285082522-24407-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 18/20] scsi-generic: add missing reset handler X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bernhard Kohl Ensure that pending requests of a SCSI generic device are purged on system reset. This also avoids calling a NULL function in lsi53c895a. The lsi code was recently changed to call the .qdev.reset function. Signed-off-by: Bernhard Kohl Signed-off-by: Kevin Wolf --- hw/scsi-generic.c | 21 +++++++++++++++++++-- 1 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c index 9538027..7212091 100644 --- a/hw/scsi-generic.c +++ b/hw/scsi-generic.c @@ -455,15 +455,31 @@ static int get_stream_blocksize(BlockDriverState *bdrv) return (buf[9] << 16) | (buf[10] << 8) | buf[11]; } -static void scsi_destroy(SCSIDevice *d) +static void scsi_generic_purge_requests(SCSIGenericState *s) { - SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, d); SCSIGenericReq *r; while (!QTAILQ_EMPTY(&s->qdev.requests)) { r = DO_UPCAST(SCSIGenericReq, req, QTAILQ_FIRST(&s->qdev.requests)); + if (r->req.aiocb) { + bdrv_aio_cancel(r->req.aiocb); + } scsi_remove_request(r); } +} + +static void scsi_generic_reset(DeviceState *dev) +{ + SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev.qdev, dev); + + scsi_generic_purge_requests(s); +} + +static void scsi_destroy(SCSIDevice *d) +{ + SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, d); + + scsi_generic_purge_requests(s); blockdev_mark_auto_del(s->qdev.conf.bs); } @@ -537,6 +553,7 @@ static SCSIDeviceInfo scsi_generic_info = { .qdev.name = "scsi-generic", .qdev.desc = "pass through generic scsi device (/dev/sg*)", .qdev.size = sizeof(SCSIGenericState), + .qdev.reset = scsi_generic_reset, .init = scsi_generic_initfn, .destroy = scsi_destroy, .send_command = scsi_send_command,