Blame SOURCES/kvm-block-Apply-auto-read-only-for-ro-whitelist-drivers.patch

7711c0
From c13468845efde058e464deeaf8b58508f33dc948 Mon Sep 17 00:00:00 2001
7711c0
From: Kevin Wolf <kwolf@redhat.com>
7711c0
Date: Tue, 19 Feb 2019 16:29:56 +0100
7711c0
Subject: [PATCH 09/23] block: Apply auto-read-only for ro-whitelist drivers
7711c0
7711c0
RH-Author: Kevin Wolf <kwolf@redhat.com>
7711c0
Message-id: <20190219162956.16183-2-kwolf@redhat.com>
7711c0
Patchwork-id: 84539
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 1/1] block: Apply auto-read-only for ro-whitelist drivers
7711c0
Bugzilla: 1667320
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
7711c0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
7711c0
If QEMU was configured with a driver in --block-drv-ro-whitelist, trying
7711c0
to use that driver read-write resulted in an error message even if
7711c0
auto-read-only=on was set.
7711c0
7711c0
Consider auto-read-only=on for the whitelist checking and use it to
7711c0
automatically degrade to read-only for block drivers on the read-only
7711c0
whitelist.
7711c0
7711c0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7711c0
Reviewed-by: Eric Blake <eblake@redhat.com>
7711c0
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
(cherry picked from commit 8be25de64315ef768353eb61f2b2bf6cddc34230)
7711c0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 block.c | 20 +++++++++++++-------
7711c0
 1 file changed, 13 insertions(+), 7 deletions(-)
7711c0
7711c0
diff --git a/block.c b/block.c
7711c0
index 82b16df..a69d0a2 100644
7711c0
--- a/block.c
7711c0
+++ b/block.c
7711c0
@@ -1418,13 +1418,19 @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file,
7711c0
     bs->read_only = !(bs->open_flags & BDRV_O_RDWR);
7711c0
 
7711c0
     if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) {
7711c0
-        error_setg(errp,
7711c0
-                   !bs->read_only && bdrv_is_whitelisted(drv, true)
7711c0
-                        ? "Driver '%s' can only be used for read-only devices"
7711c0
-                        : "Driver '%s' is not whitelisted",
7711c0
-                   drv->format_name);
7711c0
-        ret = -ENOTSUP;
7711c0
-        goto fail_opts;
7711c0
+        if (!bs->read_only && bdrv_is_whitelisted(drv, true)) {
7711c0
+            ret = bdrv_apply_auto_read_only(bs, NULL, NULL);
7711c0
+        } else {
7711c0
+            ret = -ENOTSUP;
7711c0
+        }
7711c0
+        if (ret < 0) {
7711c0
+            error_setg(errp,
7711c0
+                       !bs->read_only && bdrv_is_whitelisted(drv, true)
7711c0
+                       ? "Driver '%s' can only be used for read-only devices"
7711c0
+                       : "Driver '%s' is not whitelisted",
7711c0
+                       drv->format_name);
7711c0
+            goto fail_opts;
7711c0
+        }
7711c0
     }
7711c0
 
7711c0
     /* bdrv_new() and bdrv_close() make it so */
7711c0
-- 
7711c0
1.8.3.1
7711c0