aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'block.c')
-rw-r--r--block.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/block.c b/block.c
index 6f21145689..67ae35a47a 100644
--- a/block.c
+++ b/block.c
@@ -192,9 +192,17 @@ void path_combine(char *dest, int dest_size,
}
}
-void bdrv_set_read_only(BlockDriverState *bs, bool read_only)
+int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
{
+ /* Do not set read_only if copy_on_read is enabled */
+ if (bs->copy_on_read && read_only) {
+ error_setg(errp, "Can't set node '%s' to r/o with copy-on-read enabled",
+ bdrv_get_device_or_node_name(bs));
+ return -EINVAL;
+ }
+
bs->read_only = read_only;
+ return 0;
}
void bdrv_get_full_backing_filename_from_filename(const char *backed,