thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
26ba25
From 8cc07ae02e7cfda9605331cae792924bf18a9221 Mon Sep 17 00:00:00 2001
26ba25
From: Kevin Wolf <kwolf@redhat.com>
26ba25
Date: Thu, 10 Jan 2019 12:44:39 +0000
26ba25
Subject: [PATCH 09/14] iscsi: Support auto-read-only option
26ba25
26ba25
RH-Author: Kevin Wolf <kwolf@redhat.com>
26ba25
Message-id: <20190110124442.30132-10-kwolf@redhat.com>
26ba25
Patchwork-id: 83957
26ba25
O-Subject: [RHEL-8.0 qemu-kvm PATCH 09/12] iscsi: Support auto-read-only option
26ba25
Bugzilla: 1644996
26ba25
RH-Acked-by: Max Reitz <mreitz@redhat.com>
26ba25
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
26ba25
RH-Acked-by: Eric Blake <eblake@redhat.com>
26ba25
26ba25
If read-only=off, but auto-read-only=on is given, open the volume
26ba25
read-write if we have the permissions, but instead of erroring out for
26ba25
read-only volumes, just degrade to read-only.
26ba25
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Reviewed-by: Eric Blake <eblake@redhat.com>
26ba25
(cherry picked from commit 8f3bf50d340372662a35564c669e567c6c846943)
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 block/iscsi.c | 8 +++++---
26ba25
 1 file changed, 5 insertions(+), 3 deletions(-)
26ba25
26ba25
diff --git a/block/iscsi.c b/block/iscsi.c
26ba25
index 2b45458..c412b12 100644
26ba25
--- a/block/iscsi.c
26ba25
+++ b/block/iscsi.c
26ba25
@@ -1877,9 +1877,11 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
26ba25
     /* Check the write protect flag of the LUN if we want to write */
26ba25
     if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) &&
26ba25
         iscsilun->write_protected) {
26ba25
-        error_setg(errp, "Cannot open a write protected LUN as read-write");
26ba25
-        ret = -EACCES;
26ba25
-        goto out;
26ba25
+        ret = bdrv_apply_auto_read_only(bs, "LUN is write protected", errp);
26ba25
+        if (ret < 0) {
26ba25
+            goto out;
26ba25
+        }
26ba25
+        flags &= ~BDRV_O_RDWR;
26ba25
     }
26ba25
 
26ba25
     iscsi_readcapacity_sync(iscsilun, &local_err);
26ba25
-- 
26ba25
1.8.3.1
26ba25