From patchwork Fri Feb 24 07:54:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 142761 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (unknown [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 11073B6FC8 for ; Fri, 24 Feb 2012 18:55:00 +1100 (EST) Received: from localhost ([::1]:38148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0pzJ-0001Vz-SV for incoming@patchwork.ozlabs.org; Fri, 24 Feb 2012 02:54:45 -0500 Received: from eggs.gnu.org ([140.186.70.92]:33907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0pz8-0001VJ-OZ for qemu-devel@nongnu.org; Fri, 24 Feb 2012 02:54:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S0pz3-0000w6-0s for qemu-devel@nongnu.org; Fri, 24 Feb 2012 02:54:33 -0500 Received: from [222.73.24.84] (port=60065 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0pz2-0000rq-57 for qemu-devel@nongnu.org; Fri, 24 Feb 2012 02:54:28 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 7E36B170160; Fri, 24 Feb 2012 15:54:16 +0800 (CST) Received: from mailserver.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id q1O7sDfP031718; Fri, 24 Feb 2012 15:54:14 +0800 Received: from localhost ([10.167.225.29]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2012022415523035-766400 ; Fri, 24 Feb 2012 15:52:30 +0800 Date: Fri, 24 Feb 2012 15:54:37 +0800 From: Hu Tao To: Paolo Bonzini Message-ID: <20120224075437.GA6937@localhost.localdomain> References: <1329921236-23461-1-git-send-email-pbonzini@redhat.com> <1329921236-23461-15-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 In-Reply-To: <1329921236-23461-15-git-send-email-pbonzini@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2012-02-24 15:52:30, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2012-02-24 15:52:32, Serialize complete at 2012-02-24 15:52:32 Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: FreeBSD 6.x (1) X-Received-From: 222.73.24.84 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH v4 14/18] virtio-scsi: process control queue requests 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Wed, Feb 22, 2012 at 03:33:52PM +0100, Paolo Bonzini wrote: > Reviewed-by: Stefan Hajnoczi > Signed-off-by: Paolo Bonzini > --- > hw/virtio-scsi.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++--- > 1 files changed, 126 insertions(+), 8 deletions(-) > > diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c > index f4eb8c7..380073a 100644 > --- a/hw/virtio-scsi.c > +++ b/hw/virtio-scsi.c > @@ -134,6 +134,7 @@ typedef struct { > VirtQueue *cmd_vq; > uint32_t sense_size; > uint32_t cdb_size; > + int resetting; > } VirtIOSCSI; > > typedef struct VirtIOSCSIReq { > @@ -236,15 +237,104 @@ static VirtIOSCSIReq *virtio_scsi_pop_req(VirtIOSCSI *s, VirtQueue *vq) > return req; > } > > -static void virtio_scsi_fail_ctrl_req(VirtIOSCSIReq *req) > +static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) > { > - if (req->req.tmf->type == VIRTIO_SCSI_T_TMF) { > - req->resp.tmf->response = VIRTIO_SCSI_S_FAILURE; > - } else { > - req->resp.an->response = VIRTIO_SCSI_S_FAILURE; > + SCSIDevice *d = virtio_scsi_device_find(s, req->req.cmd->lun); should be req->req.tmf->lun here and elsewhere in this function? diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index 380073a..1f3b851 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -239,7 +239,7 @@ static VirtIOSCSIReq *virtio_scsi_pop_req(VirtIOSCSI *s, VirtQueue *vq) static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) { - SCSIDevice *d = virtio_scsi_device_find(s, req->req.cmd->lun); + SCSIDevice *d = virtio_scsi_device_find(s, req->req.tmf->lun); SCSIRequest *r, *next; DeviceState *qdev; int target; @@ -253,11 +253,11 @@ static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) if (!d) { goto fail; } - if (d->lun != virtio_scsi_get_lun(req->req.cmd->lun)) { + if (d->lun != virtio_scsi_get_lun(req->req.tmf->lun)) { goto incorrect_lun; } QTAILQ_FOREACH_SAFE(r, &d->requests, next, next) { - if (r->tag == req->req.cmd->tag) { + if (r->tag == req->req.tmf->tag) { break; } } @@ -277,7 +277,7 @@ static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) if (!d) { goto fail; } - if (d->lun != virtio_scsi_get_lun(req->req.cmd->lun)) { + if (d->lun != virtio_scsi_get_lun(req->req.tmf->lun)) { goto incorrect_lun; } s->resetting++; @@ -291,7 +291,7 @@ static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) if (!d) { goto fail; } - if (d->lun != virtio_scsi_get_lun(req->req.cmd->lun)) { + if (d->lun != virtio_scsi_get_lun(req->req.tmf->lun)) { goto incorrect_lun; } QTAILQ_FOREACH_SAFE(r, &d->requests, next, next) { @@ -310,7 +310,7 @@ static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) break; case VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET: - target = req->req.cmd->lun[1]; + target = req->req.tmf->lun[1]; s->resetting++; QTAILQ_FOREACH(qdev, &s->bus.qbus.children, sibling) { d = DO_UPCAST(SCSIDevice, qdev, qdev);