aboutsummaryrefslogtreecommitdiff
path: root/hw/block/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/block/block.c')
-rw-r--r--hw/block/block.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/hw/block/block.c b/hw/block/block.c
index 8dc9d84a39..7059ba1420 100644
--- a/hw/block/block.c
+++ b/hw/block/block.c
@@ -51,11 +51,31 @@ void blkconf_blocksizes(BlockConf *conf)
}
}
-void blkconf_apply_backend_options(BlockConf *conf)
+void blkconf_apply_backend_options(BlockConf *conf, bool readonly,
+ bool resizable, Error **errp)
{
BlockBackend *blk = conf->blk;
BlockdevOnError rerror, werror;
+ uint64_t perm, shared_perm;
bool wce;
+ int ret;
+
+ perm = BLK_PERM_CONSISTENT_READ;
+ if (!readonly) {
+ perm |= BLK_PERM_WRITE;
+ }
+
+ /* TODO Remove BLK_PERM_WRITE unless explicitly configured so */
+ shared_perm = BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED |
+ BLK_PERM_GRAPH_MOD | BLK_PERM_WRITE;
+ if (resizable) {
+ shared_perm |= BLK_PERM_RESIZE;
+ }
+
+ ret = blk_set_perm(blk, perm, shared_perm, errp);
+ if (ret < 0) {
+ return;
+ }
switch (conf->wce) {
case ON_OFF_AUTO_ON: wce = true; break;