diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2011-08-03 10:49:06 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-08-12 08:27:00 -0500 |
commit | 682a9b213ca3c47c4de5b0518c59c2e550299106 (patch) | |
tree | 3bb4e98871f5fe44a1a3ccb93288548fde22a53b /hw/scsi-disk.c | |
parent | 05751d3ff7d3c12d1468002886a71453491481ce (diff) |
scsi: pass status when completing
A small improvement in the SCSI request API. Pass the status
at the time the request is completed, so that we can assert that
no request is completed twice. This would have detected the
problem fixed in the previous patch.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/scsi-disk.c')
-rw-r--r-- | hw/scsi-disk.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index e38d9f0b75..38ebe042cb 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -102,21 +102,15 @@ static void scsi_disk_clear_sense(SCSIDiskState *s) memset(&s->sense, 0, sizeof(s->sense)); } -static void scsi_req_set_status(SCSIDiskReq *r, int status, SCSISense sense) -{ - SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); - - r->req.status = status; - s->sense = sense; -} - /* Helper function for command completion. */ static void scsi_command_complete(SCSIDiskReq *r, int status, SCSISense sense) { + SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); + DPRINTF("Command complete tag=0x%x status=%d sense=%d/%d/%d\n", r->req.tag, status, sense.key, sense.asc, sense.ascq); - scsi_req_set_status(r, status, sense); - scsi_req_complete(&r->req); + s->sense = sense; + scsi_req_complete(&r->req, status); } /* Cancel a pending data transfer. */ @@ -969,7 +963,6 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r, uint8_t *outbuf) scsi_command_complete(r, CHECK_CONDITION, SENSE_CODE(INVALID_OPCODE)); return -1; } - scsi_req_set_status(r, GOOD, SENSE_CODE(NO_SENSE)); return buflen; not_ready: |