mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-15 22:21:57 -06:00
scsi-disk: pass sense correctly for guest-recoverable errors
When an error was passed down to the guest because it was recoverable, the sense length was not copied from the SG_IO data. As a result, the guest saw the CHECK CONDITION status but not the sense data. Signed-off-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
46cd24e7ed
commit
d31347f5ff
1 changed files with 10 additions and 0 deletions
|
@ -62,6 +62,7 @@ typedef struct SCSIDiskClass {
|
||||||
DMAIOFunc *dma_readv;
|
DMAIOFunc *dma_readv;
|
||||||
DMAIOFunc *dma_writev;
|
DMAIOFunc *dma_writev;
|
||||||
bool (*need_fua_emulation)(SCSICommand *cmd);
|
bool (*need_fua_emulation)(SCSICommand *cmd);
|
||||||
|
void (*update_sense)(SCSIRequest *r);
|
||||||
} SCSIDiskClass;
|
} SCSIDiskClass;
|
||||||
|
|
||||||
typedef struct SCSIDiskReq {
|
typedef struct SCSIDiskReq {
|
||||||
|
@ -438,6 +439,7 @@ static bool scsi_handle_rw_error(SCSIDiskReq *r, int error, bool acct_failed)
|
||||||
{
|
{
|
||||||
bool is_read = (r->req.cmd.mode == SCSI_XFER_FROM_DEV);
|
bool is_read = (r->req.cmd.mode == SCSI_XFER_FROM_DEV);
|
||||||
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
|
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
|
||||||
|
SCSIDiskClass *sdc = (SCSIDiskClass *) object_get_class(OBJECT(s));
|
||||||
BlockErrorAction action = blk_get_error_action(s->qdev.conf.blk,
|
BlockErrorAction action = blk_get_error_action(s->qdev.conf.blk,
|
||||||
is_read, error);
|
is_read, error);
|
||||||
|
|
||||||
|
@ -456,6 +458,7 @@ static bool scsi_handle_rw_error(SCSIDiskReq *r, int error, bool acct_failed)
|
||||||
if (error == ECANCELED || error == EAGAIN || error == ENOTCONN ||
|
if (error == ECANCELED || error == EAGAIN || error == ENOTCONN ||
|
||||||
error == 0) {
|
error == 0) {
|
||||||
/* These errors are handled by guest. */
|
/* These errors are handled by guest. */
|
||||||
|
sdc->update_sense(&r->req);
|
||||||
scsi_req_complete(&r->req, *r->status);
|
scsi_req_complete(&r->req, *r->status);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2894,6 +2897,12 @@ static int scsi_block_parse_cdb(SCSIDevice *d, SCSICommand *cmd,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void scsi_block_update_sense(SCSIRequest *req)
|
||||||
|
{
|
||||||
|
SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
|
||||||
|
SCSIBlockReq *br = DO_UPCAST(SCSIBlockReq, req, r);
|
||||||
|
r->req.sense_len = MIN(br->io_header.sb_len_wr, sizeof(r->req.sense));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -3059,6 +3068,7 @@ static void scsi_block_class_initfn(ObjectClass *klass, void *data)
|
||||||
sc->parse_cdb = scsi_block_parse_cdb;
|
sc->parse_cdb = scsi_block_parse_cdb;
|
||||||
sdc->dma_readv = scsi_block_dma_readv;
|
sdc->dma_readv = scsi_block_dma_readv;
|
||||||
sdc->dma_writev = scsi_block_dma_writev;
|
sdc->dma_writev = scsi_block_dma_writev;
|
||||||
|
sdc->update_sense = scsi_block_update_sense;
|
||||||
sdc->need_fua_emulation = scsi_block_no_fua;
|
sdc->need_fua_emulation = scsi_block_no_fua;
|
||||||
dc->desc = "SCSI block device passthrough";
|
dc->desc = "SCSI block device passthrough";
|
||||||
dc->props = scsi_block_properties;
|
dc->props = scsi_block_properties;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue