thebeanogamer / rpms / qemu-kvm

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