[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 03/36] tests/test-bdrv-graph-mod: add test_append_greedy_filte
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v4 03/36] tests/test-bdrv-graph-mod: add test_append_greedy_filter |
Date: |
Wed, 28 Apr 2021 18:17:31 +0300 |
bdrv_append() is not quite good for inserting filters: it does extra
permission update in intermediate state, where filter get it filtered
child but is not yet replace it in a backing chain.
Some filters (for example backup-top) may want permissions even when
have no parents. And described intermediate state becomes invalid.
That's (half a) reason, why we need "inactive" state for backup-top
filter.
bdrv_append() will be improved later, now let's add a unit test.
Now test fails, so it runs only with -d flag. To run do
./test-bdrv-graph-mod -d -p /bdrv-graph-mod/append-greedy-filter
from <build-directory>/tests.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
---
tests/unit/test-bdrv-graph-mod.c | 33 ++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/tests/unit/test-bdrv-graph-mod.c b/tests/unit/test-bdrv-graph-mod.c
index a8219b131e..5b6934e68b 100644
--- a/tests/unit/test-bdrv-graph-mod.c
+++ b/tests/unit/test-bdrv-graph-mod.c
@@ -352,6 +352,37 @@ static void test_parallel_perm_update(void)
bdrv_unref(top);
}
+/*
+ * It's possible that filter required permissions allows to insert it to
backing
+ * chain, like:
+ *
+ * 1. [top] -> [filter] -> [base]
+ *
+ * but doesn't allow to add it as a branch:
+ *
+ * 2. [filter] --\
+ * v
+ * [top] -> [base]
+ *
+ * So, inserting such filter should do all graph modifications and only then
+ * update permissions. If we try to go through intermediate state [2] and
update
+ * permissions on it we'll fail.
+ *
+ * Let's check that bdrv_append() can append such a filter.
+ */
+static void test_append_greedy_filter(void)
+{
+ BlockDriverState *top = exclusive_writer_node("top");
+ BlockDriverState *base = no_perm_node("base");
+ BlockDriverState *fl = exclusive_writer_node("fl1");
+
+ bdrv_attach_child(top, base, "backing", &child_of_bds, BDRV_CHILD_COW,
+ &error_abort);
+
+ bdrv_append(fl, base, &error_abort);
+ bdrv_unref(top);
+}
+
int main(int argc, char *argv[])
{
int i;
@@ -378,6 +409,8 @@ int main(int argc, char *argv[])
test_parallel_exclusive_write);
g_test_add_func("/bdrv-graph-mod/parallel-perm-update",
test_parallel_perm_update);
+ g_test_add_func("/bdrv-graph-mod/append-greedy-filter",
+ test_append_greedy_filter);
}
return g_test_run();
--
2.29.2
- [PATCH v4 00/36] block: update graph permissions update, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 01/36] tests/test-bdrv-graph-mod: add test_parallel_exclusive_write, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 13/36] block: use topological sort for permission update, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 12/36] block: inline bdrv_child_*() permission functions calls, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 03/36] tests/test-bdrv-graph-mod: add test_append_greedy_filter,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v4 02/36] tests/test-bdrv-graph-mod: add test_parallel_perm_update, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 05/36] block: BdrvChildClass: add .get_parent_aio_context handler, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 14/36] block: add bdrv_drv_set_perm transaction action, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 06/36] block: drop ctx argument from bdrv_root_attach_child, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 16/36] block: add bdrv_replace_child_safe() transaction action, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 15/36] block: add bdrv_list_* permission update functions, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 08/36] util: add transactions.c, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 17/36] block: fix bdrv_replace_node_common, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 18/36] block: add bdrv_attach_child_common() transaction action, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 04/36] block: bdrv_append(): don't consume reference, Vladimir Sementsov-Ogievskiy, 2021/04/28