[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 26/35] scsi-generic: look at host status
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 26/35] scsi-generic: look at host status |
Date: |
Thu, 13 Oct 2011 13:03:56 +0200 |
Pass down the host status so that failing transport can be detected
by the guest. Similar treatment of host status could be done in
virtio-blk, too.
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/scsi-generic.c | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index 9043eea..787c581 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -39,8 +39,13 @@ do { fprintf(stderr, "scsi-generic: " fmt , ## __VA_ARGS__);
} while (0)
#define SCSI_SENSE_BUF_SIZE 96
-#define SG_ERR_DRIVER_TIMEOUT 0x06
-#define SG_ERR_DRIVER_SENSE 0x08
+#define SG_ERR_DRIVER_TIMEOUT 0x06
+#define SG_ERR_DRIVER_SENSE 0x08
+
+#define SG_ERR_DID_OK 0x00
+#define SG_ERR_DID_NO_CONNECT 0x01
+#define SG_ERR_DID_BUS_BUSY 0x02
+#define SG_ERR_DID_TIME_OUT 0x03
#ifndef MAX_UINT
#define MAX_UINT ((unsigned int)-1)
@@ -68,8 +73,9 @@ static void scsi_command_complete(void *opaque, int ret)
SCSIGenericReq *r = (SCSIGenericReq *)opaque;
r->req.aiocb = NULL;
- if (r->io_header.driver_status & SG_ERR_DRIVER_SENSE)
+ if (r->io_header.driver_status & SG_ERR_DRIVER_SENSE) {
r->req.sense_len = r->io_header.sb_len_wr;
+ }
if (ret != 0) {
switch (ret) {
@@ -86,9 +92,15 @@ static void scsi_command_complete(void *opaque, int ret)
break;
}
} else {
- if (r->io_header.driver_status & SG_ERR_DRIVER_TIMEOUT) {
+ if (r->io_header.host_status == SG_ERR_DID_NO_CONNECT ||
+ r->io_header.host_status == SG_ERR_DID_BUS_BUSY ||
+ r->io_header.host_status == SG_ERR_DID_TIME_OUT ||
+ (r->io_header.driver_status & SG_ERR_DRIVER_TIMEOUT)) {
status = BUSY;
BADF("Driver Timeout\n");
+ } else if (r->io_header.host_status) {
+ status = CHECK_CONDITION;
+ scsi_req_build_sense(&r->req, SENSE_CODE(I_T_NEXUS_LOSS));
} else if (r->io_header.status) {
status = r->io_header.status;
} else if (r->io_header.driver_status & SG_ERR_DRIVER_SENSE) {
--
1.7.6
- Re: [Qemu-devel] [PATCH 11/35] scsi-disk: support READ DVD STRUCTURE, (continued)
[Qemu-devel] [PATCH 16/35] scsi: implement REPORT LUNS for arbitrary LUNs, Paolo Bonzini, 2011/10/13
[Qemu-devel] [PATCH 18/35] scsi: add channel to addressing, Paolo Bonzini, 2011/10/13
[Qemu-devel] [PATCH 17/35] scsi: allow arbitrary LUNs, Paolo Bonzini, 2011/10/13
[Qemu-devel] [PATCH 22/35] scsi-disk: fix retrying a flush, Paolo Bonzini, 2011/10/13
[Qemu-devel] [PATCH 01/35] scsi: pass correct sense code for ENOMEDIUM, Paolo Bonzini, 2011/10/13
[Qemu-devel] [PATCH 25/35] scsi-generic: check ioctl statuses when SG_IO succeeds, Paolo Bonzini, 2011/10/13
[Qemu-devel] [PATCH 24/35] scsi-generic: remove scsi_req_fixup, Paolo Bonzini, 2011/10/13
[Qemu-devel] [PATCH 23/35] scsi-generic: drop SCSIGenericState, Paolo Bonzini, 2011/10/13
[Qemu-devel] [PATCH 26/35] scsi-generic: look at host status,
Paolo Bonzini <=
[Qemu-devel] [PATCH 33/35] scsi: export scsi_generic_reqops, Paolo Bonzini, 2011/10/13
[Qemu-devel] [PATCH 32/35] scsi: make reqops static const, Paolo Bonzini, 2011/10/13
[Qemu-devel] [PATCH 20/35] scsi-disk: do not complete requests twice, Paolo Bonzini, 2011/10/13
[Qemu-devel] [PATCH 19/35] scsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0, Paolo Bonzini, 2011/10/13
[Qemu-devel] [PATCH 35/35] scsi-disk: add scsi-block for device passthrough, Paolo Bonzini, 2011/10/13
[Qemu-devel] [PATCH 12/35] scsi-disk: report media changed via GET EVENT STATUS NOTIFICATION, Paolo Bonzini, 2011/10/13