[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 19/20] scsi-disk: reject ANCHOR=1 for UNMAP and W
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH v2 19/20] scsi-disk: reject ANCHOR=1 for UNMAP and WRITE SAME commands |
Date: |
Tue, 19 Nov 2013 18:07:42 +0100 |
Since we report ANC_SUP==0 in VPD page B2h, we need to return
an error (ILLEGAL REQUEST/INVALID FIELD IN CDB) for all WRITE SAME
requests with ANCHOR==1.
Inspired by a similar patch to the LIO in-kernel target.
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/scsi/scsi-disk.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 4138268..0640bb0 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -1548,6 +1548,11 @@ static void scsi_disk_emulate_unmap(SCSIDiskReq *r,
uint8_t *inbuf)
int len = r->req.cmd.xfer;
UnmapCBData *data;
+ /* Reject ANCHOR=1. */
+ if (r->req.cmd.buf[1] & 0x1) {
+ goto invalid_field;
+ }
+
if (len < 8) {
goto invalid_param_len;
}
@@ -1578,6 +1583,10 @@ static void scsi_disk_emulate_unmap(SCSIDiskReq *r,
uint8_t *inbuf)
invalid_param_len:
scsi_check_condition(r, SENSE_CODE(INVALID_PARAM_LEN));
+ return;
+
+invalid_field:
+ scsi_check_condition(r, SENSE_CODE(INVALID_FIELD));
}
static void scsi_disk_emulate_write_data(SCSIRequest *req)
@@ -1856,8 +1865,9 @@ static int32_t scsi_disk_emulate_command(SCSIRequest
*req, uint8_t *buf)
/*
* We only support WRITE SAME with the unmap bit set for now.
+ * Reject UNMAP=0 or ANCHOR=1.
*/
- if (!(req->cmd.buf[1] & 0x8)) {
+ if (!(req->cmd.buf[1] & 0x8) || (req->cmd.buf[1] & 0x10)) {
goto illegal_request;
}
--
1.8.4.2
- [Qemu-devel] [PATCH v2 13/20] block/iscsi: use UNMAP to write zeroes if LBPRZ=1, (continued)
[Qemu-devel] [PATCH v2 14/20] raw-posix: implement write_zeroes with MAY_UNMAP for files, Paolo Bonzini, 2013/11/19
[Qemu-devel] [PATCH v2 15/20] raw-posix: implement write_zeroes with MAY_UNMAP for block devices, Paolo Bonzini, 2013/11/19
[Qemu-devel] [PATCH v2 16/20] raw-posix: add support for write_zeroes on XFS and block devices, Paolo Bonzini, 2013/11/19
[Qemu-devel] [PATCH v2 17/20] qemu-iotests: 033 is fast, Paolo Bonzini, 2013/11/19
[Qemu-devel] [PATCH v2 18/20] scsi-disk: catch write protection errors in UNMAP, Paolo Bonzini, 2013/11/19
[Qemu-devel] [PATCH v2 19/20] scsi-disk: reject ANCHOR=1 for UNMAP and WRITE SAME commands,
Paolo Bonzini <=
[Qemu-devel] [PATCH v2 20/20] scsi-disk: correctly implement WRITE SAME, Paolo Bonzini, 2013/11/19