aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'block.c')
-rw-r--r--block.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/block.c b/block.c
index 123c98279b..1ac05c1394 100644
--- a/block.c
+++ b/block.c
@@ -197,7 +197,7 @@ bool bdrv_is_read_only(BlockDriverState *bs)
return bs->read_only;
}
-int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
+int bdrv_can_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) {
@@ -213,6 +213,18 @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
return -EPERM;
}
+ return 0;
+}
+
+int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
+{
+ int ret = 0;
+
+ ret = bdrv_can_set_read_only(bs, read_only, errp);
+ if (ret < 0) {
+ return ret;
+ }
+
bs->read_only = read_only;
return 0;
}