Received: from eggs.gnu.org ([140.186.70.92]:42976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHIoB-0004FB-Mp for qemu-devel@nongnu.org; Tue, 03 May 2011 12:50:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QHIoA-0000ER-Qg for qemu-devel@nongnu.org; Tue, 03 May 2011 12:50:47 -0400 Received: from mail-wy0-f173.google.com ([74.125.82.173]:61623) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHIoA-0000Ci-MJ for qemu-devel@nongnu.org; Tue, 03 May 2011 12:50:46 -0400 Received: by mail-wy0-f173.google.com with SMTP id 42so248862wyb.4 for ; Tue, 03 May 2011 09:50:46 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 3 May 2011 18:50:21 +0200 Message-Id: <1304441432-27434-10-git-send-email-pbonzini@redhat.com> In-Reply-To: <1304441432-27434-1-git-send-email-pbonzini@redhat.com> References: <1304441432-27434-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 09/20] scsi: introduce scsi_req_abort List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This covers the case of canceling a request's I/O and still completing it. Signed-off-by: Paolo Bonzini --- hw/scsi-bus.c | 9 +++++++++ hw/scsi.h | 1 + hw/spapr_vscsi.c | 8 ++------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index e1bb494..1d7da9e 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -548,6 +548,15 @@ void scsi_req_complete(SCSIRequest *req) scsi_req_unref(req); } +void scsi_req_abort(SCSIRequest *req, int status) +{ + req->status = status; + if (req->dev && req->dev->info->cancel_io) { + req->dev->info->cancel_io(req); + } + scsi_req_complete(req); +} + void scsi_device_purge_requests(SCSIDevice *sdev) { SCSIRequest *req; diff --git a/hw/scsi.h b/hw/scsi.h index dee8567..6221fff 100644 --- a/hw/scsi.h +++ b/hw/scsi.h @@ -114,6 +114,7 @@ int scsi_req_parse(SCSIRequest *req, uint8_t *buf); void scsi_req_print(SCSIRequest *req); void scsi_req_data(SCSIRequest *req, int len); void scsi_req_complete(SCSIRequest *req); +void scsi_req_abort(SCSIRequest *req, int status); void scsi_device_purge_requests(SCSIDevice *sdev); #endif diff --git a/hw/spapr_vscsi.c b/hw/spapr_vscsi.c index cf2ed73..678cd00 100644 --- a/hw/spapr_vscsi.c +++ b/hw/spapr_vscsi.c @@ -463,10 +463,8 @@ static void vscsi_send_request_sense(VSCSIState *s, vscsi_req *req) dprintf("VSCSI: Queued request sense tag 0x%x\n", req->qtag); if (n < 0) { fprintf(stderr, "VSCSI: REQUEST_SENSE wants write data !?!?!?\n"); - sdev->info->cancel_io(req->sreq); vscsi_makeup_sense(s, req, HARDWARE_ERROR, 0, 0); - vscsi_send_rsp(s, req, CHECK_CONDITION, 0, 0); - vscsi_put_req(s, req); + scsi_req_abort(req->sreq, CHECK_CONDITION); return; } else if (n == 0) { return; @@ -547,10 +545,8 @@ static void vscsi_command_complete(SCSIRequest *sreq, int reason, uint32_t arg) } if (rc < 0) { fprintf(stderr, "VSCSI: RDMA error rc=%d!\n", rc); - sdev->info->cancel_io(sreq); vscsi_makeup_sense(s, req, HARDWARE_ERROR, 0, 0); - vscsi_send_rsp(s, req, CHECK_CONDITION, 0, 0); - vscsi_put_req(s, req); + scsi_req_abort(req->sreq, CHECK_CONDITION); return; } -- 1.7.4.4