diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-02-08 10:40:37 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2012-05-04 10:39:52 +0200 |
commit | a5ee9085627eaeb501db31e3758df4e18500be71 (patch) | |
tree | 587aa233f8d13ae3f3ad1129247d5636b58e3f40 | |
parent | 31e8fd86f24b4eec8a1708d712bf0532460bb0a5 (diff) |
scsi: fix WRITE SAME transfer length and direction
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | hw/scsi-bus.c | 14 | ||||
-rw-r--r-- | hw/scsi-disk.c | 5 |
2 files changed, 12 insertions, 7 deletions
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index c29a4aea4a..5640aae68d 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -791,7 +791,8 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf) case MODE_SENSE: break; case WRITE_SAME_10: - cmd->xfer = 1; + case WRITE_SAME_16: + cmd->xfer = dev->blocksize; break; case READ_CAPACITY_10: cmd->xfer = 8; @@ -909,6 +910,10 @@ static int scsi_req_stream_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *bu static void scsi_cmd_xfer_mode(SCSICommand *cmd) { + if (!cmd->xfer) { + cmd->mode = SCSI_XFER_NONE; + return; + } switch (cmd->buf[0]) { case WRITE_6: case WRITE_10: @@ -934,6 +939,7 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd) case UPDATE_BLOCK: case WRITE_LONG_10: case WRITE_SAME_10: + case WRITE_SAME_16: case SEARCH_HIGH_12: case SEARCH_EQUAL_12: case SEARCH_LOW_12: @@ -946,11 +952,7 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd) cmd->mode = SCSI_XFER_TO_DEV; break; default: - if (cmd->xfer) - cmd->mode = SCSI_XFER_FROM_DEV; - else { - cmd->mode = SCSI_XFER_NONE; - } + cmd->mode = SCSI_XFER_FROM_DEV; break; } } diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index eca00a6b1d..fbb10415cb 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1566,8 +1566,11 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf) } break; case WRITE_SAME_10: + len = lduw_be_p(&buf[7]); + goto write_same; case WRITE_SAME_16: - len = r->req.cmd.xfer / s->qdev.blocksize; + len = ldl_be_p(&buf[10]) & 0xffffffffULL; + write_same: DPRINTF("WRITE SAME() (sector %" PRId64 ", count %d)\n", r->req.cmd.lba, len); |