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