yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From 25760de201dc5c29d171fc4ae4f34d6eaabbdad6 Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <25760de201dc5c29d171fc4ae4f34d6eaabbdad6.1389014116.git.minovotn@redhat.com>
0a122b
In-Reply-To: <c8cc35838d42aa286242772d97e3a9be7bb786ba.1389014116.git.minovotn@redhat.com>
0a122b
References: <c8cc35838d42aa286242772d97e3a9be7bb786ba.1389014116.git.minovotn@redhat.com>
0a122b
From: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Date: Mon, 9 Dec 2013 14:09:23 +0100
0a122b
Subject: [PATCH 35/50] scsi-disk: catch write protection errors in UNMAP
0a122b
0a122b
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Message-id: <1386598178-11845-38-git-send-email-pbonzini@redhat.com>
0a122b
Patchwork-id: 56074
0a122b
O-Subject: [RHEL 7.0 qemu-kvm PATCH 37/52] scsi-disk: catch write protection errors in UNMAP
0a122b
Bugzilla: 1007815
0a122b
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
0a122b
RH-Acked-by: Fam Zheng <famz@redhat.com>
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
0a122b
This is the same that is already done for WRITE SAME.
0a122b
0a122b
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
(cherry picked from commit c5fd1fb038405ed13496761970b3b531f747a892)
0a122b
---
0a122b
 hw/scsi/scsi-disk.c | 6 ++++++
0a122b
 1 file changed, 6 insertions(+)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 hw/scsi/scsi-disk.c | 6 ++++++
0a122b
 1 file changed, 6 insertions(+)
0a122b
0a122b
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
0a122b
index 74e6a14..4138268 100644
0a122b
--- a/hw/scsi/scsi-disk.c
0a122b
+++ b/hw/scsi/scsi-disk.c
0a122b
@@ -1543,6 +1543,7 @@ done:
0a122b
 
0a122b
 static void scsi_disk_emulate_unmap(SCSIDiskReq *r, uint8_t *inbuf)
0a122b
 {
0a122b
+    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
0a122b
     uint8_t *p = inbuf;
0a122b
     int len = r->req.cmd.xfer;
0a122b
     UnmapCBData *data;
0a122b
@@ -1560,6 +1561,11 @@ static void scsi_disk_emulate_unmap(SCSIDiskReq *r, uint8_t *inbuf)
0a122b
         goto invalid_param_len;
0a122b
     }
0a122b
 
0a122b
+    if (bdrv_is_read_only(s->qdev.conf.bs)) {
0a122b
+        scsi_check_condition(r, SENSE_CODE(WRITE_PROTECTED));
0a122b
+        return;
0a122b
+    }
0a122b
+
0a122b
     data = g_new0(UnmapCBData, 1);
0a122b
     data->r = r;
0a122b
     data->inbuf = &p[8];
0a122b
-- 
0a122b
1.7.11.7
0a122b