qemu-kvm/SOURCES/kvm-block-Update-flags-in-bdrv_set_read_only.patch

49 lines
1.4 KiB
Diff

From 03d1ed6853d936e90ed1661433f822b4a360e5fa Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Thu, 10 Jan 2019 12:44:31 +0000
Subject: [PATCH 01/14] block: Update flags in bdrv_set_read_only()
RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <20190110124442.30132-2-kwolf@redhat.com>
Patchwork-id: 83949
O-Subject: [RHEL-8.0 qemu-kvm PATCH 01/12] block: Update flags in bdrv_set_read_only()
Bugzilla: 1644996
RH-Acked-by: Max Reitz <mreitz@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Eric Blake <eblake@redhat.com>
To fully change the read-only state of a node, we must not only change
bs->read_only, but also update bs->open_flags.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
(cherry picked from commit eeae6a596b0efc092f5101c67683053e245e6250)
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
block.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/block.c b/block.c
index 73f55a1..6f1d53b 100644
--- a/block.c
+++ b/block.c
@@ -281,6 +281,13 @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
}
bs->read_only = read_only;
+
+ if (read_only) {
+ bs->open_flags &= ~BDRV_O_RDWR;
+ } else {
+ bs->open_flags |= BDRV_O_RDWR;
+ }
+
return 0;
}
--
1.8.3.1