From 03d1ed6853d936e90ed1661433f822b4a360e5fa Mon Sep 17 00:00:00 2001 From: Kevin Wolf 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 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 RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Eric Blake 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 Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia (cherry picked from commit eeae6a596b0efc092f5101c67683053e245e6250) Signed-off-by: Kevin Wolf Signed-off-by: Danilo C. L. de Paula --- 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