scsi-disk: rd/wr/vr-protect !=0 is an error
The QEMU SCSI emulation does not support protection information, so any READ/WRITE/VERIFY commands that has the protect bits set to non-zero should fail with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB From SCSI SBC : If the logical unit does not support protection information, then the device server should terminate the command with CHECK CONDITION status with the sense key set to ILLEGAL REQUEST and the additional sense code set to INVALID FIELD IN CDB. Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com> [ Rebase after scsi_dma_reqops introduction - Paolo ] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
96c91bbf60
commit
96bdbbab55
|
@ -1774,6 +1774,9 @@ static int32_t scsi_disk_dma_command(SCSIRequest *req, uint8_t *buf)
|
||||||
case READ_16:
|
case READ_16:
|
||||||
len = r->req.cmd.xfer / s->qdev.blocksize;
|
len = r->req.cmd.xfer / s->qdev.blocksize;
|
||||||
DPRINTF("Read (sector %" PRId64 ", count %d)\n", r->req.cmd.lba, len);
|
DPRINTF("Read (sector %" PRId64 ", count %d)\n", r->req.cmd.lba, len);
|
||||||
|
if (r->req.cmd.buf[1] & 0xe0) {
|
||||||
|
goto illegal_request;
|
||||||
|
}
|
||||||
if (r->req.cmd.lba > s->qdev.max_lba) {
|
if (r->req.cmd.lba > s->qdev.max_lba) {
|
||||||
goto illegal_lba;
|
goto illegal_lba;
|
||||||
}
|
}
|
||||||
|
@ -1794,6 +1797,9 @@ static int32_t scsi_disk_dma_command(SCSIRequest *req, uint8_t *buf)
|
||||||
DPRINTF("Write %s(sector %" PRId64 ", count %d)\n",
|
DPRINTF("Write %s(sector %" PRId64 ", count %d)\n",
|
||||||
(command & 0xe) == 0xe ? "And Verify " : "",
|
(command & 0xe) == 0xe ? "And Verify " : "",
|
||||||
r->req.cmd.lba, len);
|
r->req.cmd.lba, len);
|
||||||
|
if (r->req.cmd.buf[1] & 0xe0) {
|
||||||
|
goto illegal_request;
|
||||||
|
}
|
||||||
if (r->req.cmd.lba > s->qdev.max_lba) {
|
if (r->req.cmd.lba > s->qdev.max_lba) {
|
||||||
goto illegal_lba;
|
goto illegal_lba;
|
||||||
}
|
}
|
||||||
|
@ -1802,6 +1808,9 @@ static int32_t scsi_disk_dma_command(SCSIRequest *req, uint8_t *buf)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
|
illegal_request:
|
||||||
|
scsi_check_condition(r, SENSE_CODE(INVALID_FIELD));
|
||||||
|
return 0;
|
||||||
illegal_lba:
|
illegal_lba:
|
||||||
scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE));
|
scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue