[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 10/34] block/copy-before-write: relax permission requirements
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v8 10/34] block/copy-before-write: relax permission requirements when no parents |
Date: |
Tue, 24 Aug 2021 11:38:32 +0300 |
We are going to publish copy-before-write filter. So, user should be
able to create it with blockdev-add first, specifying both filtered and
target children. And then do blockdev-reopen, to actually insert the
filter where needed.
Currently, filter unshares write permission unconditionally on source
node. It's good, but it will not allow to do blockdev-add. So, let's
relax restrictions when filter doesn't have any parent.
Test output is modified, as now permission conflict happens only when
job creates a blk parent for filter node.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
block/copy-before-write.c | 8 +++++---
tests/qemu-iotests/283.out | 2 +-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
index a7996d54db..2a51cc64e4 100644
--- a/block/copy-before-write.c
+++ b/block/copy-before-write.c
@@ -142,10 +142,12 @@ static void cbw_child_perm(BlockDriverState *bs,
BdrvChild *c,
bdrv_default_perms(bs, c, role, reopen_queue,
perm, shared, nperm, nshared);
- if (perm & BLK_PERM_WRITE) {
- *nperm = *nperm | BLK_PERM_CONSISTENT_READ;
+ if (!QLIST_EMPTY(&bs->parents)) {
+ if (perm & BLK_PERM_WRITE) {
+ *nperm = *nperm | BLK_PERM_CONSISTENT_READ;
+ }
+ *nshared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
}
- *nshared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
}
}
diff --git a/tests/qemu-iotests/283.out b/tests/qemu-iotests/283.out
index f2b7219632..5bb75952ef 100644
--- a/tests/qemu-iotests/283.out
+++ b/tests/qemu-iotests/283.out
@@ -5,7 +5,7 @@
{"execute": "blockdev-add", "arguments": {"driver": "blkdebug", "image":
"base", "node-name": "other", "take-child-perms": ["write"]}}
{"return": {}}
{"execute": "blockdev-backup", "arguments": {"device": "source", "sync":
"full", "target": "target"}}
-{"error": {"class": "GenericError", "desc": "Cannot append copy-before-write
filter: Permission conflict on node 'base': permissions 'write' are both
required by node 'other' (uses node 'base' as 'image' child) and unshared by
node 'source' (uses node 'base' as 'image' child)."}}
+{"error": {"class": "GenericError", "desc": "Permission conflict on node
'base': permissions 'write' are both required by node 'other' (uses node 'base'
as 'image' child) and unshared by node 'source' (uses node 'base' as 'image'
child)."}}
=== copy-before-write filter should be gone after job-finalize ===
--
2.29.2
- [PATCH v8 04/34] qdev: allow setting drive property for realized device, (continued)
- [PATCH v8 04/34] qdev: allow setting drive property for realized device, Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 09/34] block/backup: move cluster size calculation to block-copy, Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 05/34] block: rename backup-top to copy-before-write, Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 11/34] block/copy-before-write: drop extra bdrv_unref on failure path, Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 15/34] block/copy-before-write: cbw_init(): rename variables, Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 14/34] block/copy-before-write: introduce cbw_init(), Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 16/34] block/copy-before-write: cbw_init(): use file child after attaching, Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 01/34] block: introduce bdrv_replace_child_bs(), Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 18/34] block/copy-before-write: cbw_init(): use options, Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 19/34] block/copy-before-write: initialize block-copy bitmap, Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 10/34] block/copy-before-write: relax permission requirements when no parents,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v8 26/34] iotests/222: fix pylint and mypy complains, Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 17/34] block/copy-before-write: bdrv_cbw_append(): drop unused compress arg, Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 21/34] block/copy-before-write: make public block driver, Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 23/34] python/qemu/machine.py: refactor _qemu_args(), Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 25/34] python:QEMUMachine: template typing for self returning methods, Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 20/34] block/block-copy: make setting progress optional, Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 22/34] qapi: publish copy-before-write filter, Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 24/34] python/qemu/machine: QEMUMachine: improve qmp() method, Vladimir Sementsov-Ogievskiy, 2021/08/24
- [PATCH v8 27/34] iotests/222: constantly use single quotes for strings, Vladimir Sementsov-Ogievskiy, 2021/08/24