Blame SOURCES/kvm-iscsi-Support-auto-read-only-option.patch

7711c0
From 546f992fdc25fd65f050efff3b4c8bf8f22d5a05 Mon Sep 17 00:00:00 2001
7711c0
From: Kevin Wolf <kwolf@redhat.com>
7711c0
Date: Fri, 23 Nov 2018 10:41:51 +0100
7711c0
Subject: [PATCH 10/34] iscsi: Support auto-read-only option
7711c0
7711c0
RH-Author: Kevin Wolf <kwolf@redhat.com>
7711c0
Message-id: <20181123104154.13541-10-kwolf@redhat.com>
7711c0
Patchwork-id: 83120
7711c0
O-Subject: [RHEL-7.7/7.6.z qemu-kvm-rhev PATCH v2 09/12] iscsi: Support auto-read-only option
7711c0
Bugzilla: 1623986
7711c0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
RH-Acked-by: John Snow <jsnow@redhat.com>
7711c0
7711c0
If read-only=off, but auto-read-only=on is given, open the volume
7711c0
read-write if we have the permissions, but instead of erroring out for
7711c0
read-only volumes, just degrade to read-only.
7711c0
7711c0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7711c0
Reviewed-by: Eric Blake <eblake@redhat.com>
7711c0
(cherry picked from commit 8f3bf50d340372662a35564c669e567c6c846943)
7711c0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 block/iscsi.c | 8 +++++---
7711c0
 1 file changed, 5 insertions(+), 3 deletions(-)
7711c0
7711c0
diff --git a/block/iscsi.c b/block/iscsi.c
7711c0
index 2b45458..c412b12 100644
7711c0
--- a/block/iscsi.c
7711c0
+++ b/block/iscsi.c
7711c0
@@ -1877,9 +1877,11 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
7711c0
     /* Check the write protect flag of the LUN if we want to write */
7711c0
     if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) &&
7711c0
         iscsilun->write_protected) {
7711c0
-        error_setg(errp, "Cannot open a write protected LUN as read-write");
7711c0
-        ret = -EACCES;
7711c0
-        goto out;
7711c0
+        ret = bdrv_apply_auto_read_only(bs, "LUN is write protected", errp);
7711c0
+        if (ret < 0) {
7711c0
+            goto out;
7711c0
+        }
7711c0
+        flags &= ~BDRV_O_RDWR;
7711c0
     }
7711c0
 
7711c0
     iscsi_readcapacity_sync(iscsilun, &local_err);
7711c0
-- 
7711c0
1.8.3.1
7711c0