aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi/scsi-disk.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2013-11-22 13:39:59 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2013-12-03 15:26:49 +0100
commitc5fd1fb038405ed13496761970b3b531f747a892 (patch)
treec4e5a59239d329818debc5e2fa3c2f9b8bb74ad3 /hw/scsi/scsi-disk.c
parente18d90c15bab0d47d8f30696058abfb78396081f (diff)
downloadqemu-c5fd1fb038405ed13496761970b3b531f747a892.zip
qemu-c5fd1fb038405ed13496761970b3b531f747a892.tar.gz
qemu-c5fd1fb038405ed13496761970b3b531f747a892.tar.bz2
scsi-disk: catch write protection errors in UNMAP
This is the same that is already done for WRITE SAME. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'hw/scsi/scsi-disk.c')
-rw-r--r--hw/scsi/scsi-disk.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 74e6a14..4138268 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -1543,6 +1543,7 @@ done:
static void scsi_disk_emulate_unmap(SCSIDiskReq *r, uint8_t *inbuf)
{
+ SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint8_t *p = inbuf;
int len = r->req.cmd.xfer;
UnmapCBData *data;
@@ -1560,6 +1561,11 @@ static void scsi_disk_emulate_unmap(SCSIDiskReq *r, uint8_t *inbuf)
goto invalid_param_len;
}
+ if (bdrv_is_read_only(s->qdev.conf.bs)) {
+ scsi_check_condition(r, SENSE_CODE(WRITE_PROTECTED));
+ return;
+ }
+
data = g_new0(UnmapCBData, 1);
data->r = r;
data->inbuf = &p[8];