aboutsummaryrefslogtreecommitdiff
path: root/hw/block
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2017-01-24 13:58:00 +0100
committerKevin Wolf <kwolf@redhat.com>2017-02-28 20:40:36 +0100
commitdabd18f64c8800d441fd9fb232c2102e8409aa2e (patch)
tree96cd8be59b9a5f045edca263974b08d26f169884 /hw/block
parenta17c17a274f24f0c0259f89d288f29b8ce0511aa (diff)
downloadqemu-dabd18f64c8800d441fd9fb232c2102e8409aa2e.zip
qemu-dabd18f64c8800d441fd9fb232c2102e8409aa2e.tar.gz
qemu-dabd18f64c8800d441fd9fb232c2102e8409aa2e.tar.bz2
hw/block: Introduce share-rw qdev property
By default, don't allow another writer for block devices that are attached to a guest device. For the cases where this setup is intended (e.g. using a cluster filesystem on the disk), the new option can be used to allow it. This change affects only devices using DEFINE_BLOCK_PROPERTIES(). Devices directly using DEFINE_PROP_DRIVE() still accept writers unconditionally. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Acked-by: Fam Zheng <famz@redhat.com>
Diffstat (limited to 'hw/block')
-rw-r--r--hw/block/block.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/hw/block/block.c b/hw/block/block.c
index 7059ba1..27878d0 100644
--- a/hw/block/block.c
+++ b/hw/block/block.c
@@ -65,12 +65,14 @@ void blkconf_apply_backend_options(BlockConf *conf, bool 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;
+ BLK_PERM_GRAPH_MOD;
if (resizable) {
shared_perm |= BLK_PERM_RESIZE;
}
+ if (conf->share_rw) {
+ shared_perm |= BLK_PERM_WRITE;
+ }
ret = blk_set_perm(blk, perm, shared_perm, errp);
if (ret < 0) {