From: Kevin Wolf Date: Tue, 9 Oct 2018 14:57:12 +0000 (+0200) Subject: block: Update flags in bdrv_set_read_only() X-Git-Tag: v3.1.0-rc0~8^2~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eeae6a596b0efc092f5101c67683053e245e6250;p=thirdparty%2Fqemu.git block: Update flags in bdrv_set_read_only() 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 --- diff --git a/block.c b/block.c index 9d2adf79623..3132c78f010 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; }