提交 a5ee9085 编写于 作者: P Paolo Bonzini

scsi: fix WRITE SAME transfer length and direction

Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 31e8fd86
...@@ -791,7 +791,8 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf) ...@@ -791,7 +791,8 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)
case MODE_SENSE: case MODE_SENSE:
break; break;
case WRITE_SAME_10: case WRITE_SAME_10:
cmd->xfer = 1; case WRITE_SAME_16:
cmd->xfer = dev->blocksize;
break; break;
case READ_CAPACITY_10: case READ_CAPACITY_10:
cmd->xfer = 8; cmd->xfer = 8;
...@@ -909,6 +910,10 @@ static int scsi_req_stream_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *bu ...@@ -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) static void scsi_cmd_xfer_mode(SCSICommand *cmd)
{ {
if (!cmd->xfer) {
cmd->mode = SCSI_XFER_NONE;
return;
}
switch (cmd->buf[0]) { switch (cmd->buf[0]) {
case WRITE_6: case WRITE_6:
case WRITE_10: case WRITE_10:
...@@ -934,6 +939,7 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd) ...@@ -934,6 +939,7 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd)
case UPDATE_BLOCK: case UPDATE_BLOCK:
case WRITE_LONG_10: case WRITE_LONG_10:
case WRITE_SAME_10: case WRITE_SAME_10:
case WRITE_SAME_16:
case SEARCH_HIGH_12: case SEARCH_HIGH_12:
case SEARCH_EQUAL_12: case SEARCH_EQUAL_12:
case SEARCH_LOW_12: case SEARCH_LOW_12:
...@@ -946,11 +952,7 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd) ...@@ -946,11 +952,7 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd)
cmd->mode = SCSI_XFER_TO_DEV; cmd->mode = SCSI_XFER_TO_DEV;
break; break;
default: default:
if (cmd->xfer) cmd->mode = SCSI_XFER_FROM_DEV;
cmd->mode = SCSI_XFER_FROM_DEV;
else {
cmd->mode = SCSI_XFER_NONE;
}
break; break;
} }
} }
......
...@@ -1566,8 +1566,11 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf) ...@@ -1566,8 +1566,11 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf)
} }
break; break;
case WRITE_SAME_10: case WRITE_SAME_10:
len = lduw_be_p(&buf[7]);
goto write_same;
case WRITE_SAME_16: 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", DPRINTF("WRITE SAME() (sector %" PRId64 ", count %d)\n",
r->req.cmd.lba, len); r->req.cmd.lba, len);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册