diff --git a/block.c b/block.c index 9d2adf79623907b42e73482701def00bbc3bb1ea..3132c78f0104b3f9d95d3f715fbfc7e847e504c4 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; }