aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2018-10-09 16:57:12 +0200
committerKevin Wolf <kwolf@redhat.com>2018-11-05 15:09:55 +0100
commiteeae6a596b0efc092f5101c67683053e245e6250 (patch)
treeaac0249cb431b4924304c646ffd11b738d044f9b /block.c
parent04f600ef7cacaa2a81b74b2cdd3670cfc106d0e2 (diff)
downloadqemu-eeae6a596b0efc092f5101c67683053e245e6250.zip
qemu-eeae6a596b0efc092f5101c67683053e245e6250.tar.gz
qemu-eeae6a596b0efc092f5101c67683053e245e6250.tar.bz2
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 <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/block.c b/block.c
index 9d2adf7..3132c78 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;
}