From c5fd1fb038405ed13496761970b3b531f747a892 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 22 Nov 2013 13:39:59 +0100 Subject: scsi-disk: catch write protection errors in UNMAP This is the same that is already done for WRITE SAME. Signed-off-by: Paolo Bonzini Signed-off-by: Stefan Hajnoczi --- hw/scsi/scsi-disk.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'hw/scsi/scsi-disk.c') 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]; -- cgit v1.1