diff options
author | Kevin Wolf <kwolf@redhat.com> | 2017-01-24 13:43:31 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2017-02-28 20:40:36 +0100 |
commit | a17c17a274f24f0c0259f89d288f29b8ce0511aa (patch) | |
tree | 592723a71539dd34bdb76b7fe74f9898be7dcb90 /hw/block/block.c | |
parent | 39829a01ae524788c68dc0794e6912faa898eb75 (diff) |
hw/block: Request permissions
This makes all device emulations with a qdev drive property request
permissions on their BlockBackend. The only thing we block at this point
is resizing images for some devices that can't support it.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Acked-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'hw/block/block.c')
-rw-r--r-- | hw/block/block.c | 22 |
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; |