mirror of https://github.com/xemu-project/xemu.git
scsi-generic: look at host status
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 <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
fe0ed71279
commit
a3b16e71ab
|
@ -42,6 +42,11 @@ do { fprintf(stderr, "scsi-generic: " fmt , ## __VA_ARGS__); } while (0)
|
||||||
#define SG_ERR_DRIVER_TIMEOUT 0x06
|
#define SG_ERR_DRIVER_TIMEOUT 0x06
|
||||||
#define SG_ERR_DRIVER_SENSE 0x08
|
#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
|
#ifndef MAX_UINT
|
||||||
#define MAX_UINT ((unsigned int)-1)
|
#define MAX_UINT ((unsigned int)-1)
|
||||||
#endif
|
#endif
|
||||||
|
@ -68,8 +73,9 @@ static void scsi_command_complete(void *opaque, int ret)
|
||||||
SCSIGenericReq *r = (SCSIGenericReq *)opaque;
|
SCSIGenericReq *r = (SCSIGenericReq *)opaque;
|
||||||
|
|
||||||
r->req.aiocb = NULL;
|
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;
|
r->req.sense_len = r->io_header.sb_len_wr;
|
||||||
|
}
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
|
@ -86,9 +92,15 @@ static void scsi_command_complete(void *opaque, int ret)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
status = BUSY;
|
||||||
BADF("Driver Timeout\n");
|
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) {
|
} else if (r->io_header.status) {
|
||||||
status = r->io_header.status;
|
status = r->io_header.status;
|
||||||
} else if (r->io_header.driver_status & SG_ERR_DRIVER_SENSE) {
|
} else if (r->io_header.driver_status & SG_ERR_DRIVER_SENSE) {
|
||||||
|
|
Loading…
Reference in New Issue