|
|
357786 |
From 7a587bf1f9cac772532a41e31202fd7ef8646928 Mon Sep 17 00:00:00 2001
|
|
|
357786 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
Date: Fri, 14 Sep 2018 10:55:09 +0200
|
|
|
357786 |
Subject: [PATCH 18/49] test-bdrv-drain: Test node deletion in subtree
|
|
|
357786 |
recursion
|
|
|
357786 |
|
|
|
357786 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
Message-id: <20180914105540.18077-12-kwolf@redhat.com>
|
|
|
357786 |
Patchwork-id: 82159
|
|
|
357786 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 11/42] test-bdrv-drain: Test node deletion in subtree recursion
|
|
|
357786 |
Bugzilla: 1601212
|
|
|
357786 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
357786 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
357786 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
357786 |
|
|
|
357786 |
If bdrv_do_drained_begin() polls during its subtree recursion, the graph
|
|
|
357786 |
can change and mess up the bs->children iteration. Test that this
|
|
|
357786 |
doesn't happen.
|
|
|
357786 |
|
|
|
357786 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
(cherry picked from commit ebd31837618cdc7bda83090773dcdd87475d55b7)
|
|
|
357786 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
357786 |
---
|
|
|
357786 |
tests/test-bdrv-drain.c | 38 +++++++++++++++++++++++++++++---------
|
|
|
357786 |
1 file changed, 29 insertions(+), 9 deletions(-)
|
|
|
357786 |
|
|
|
357786 |
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
|
|
|
357786 |
index 8918a94..38706b0 100644
|
|
|
357786 |
--- a/tests/test-bdrv-drain.c
|
|
|
357786 |
+++ b/tests/test-bdrv-drain.c
|
|
|
357786 |
@@ -875,7 +875,8 @@ static void coroutine_fn test_co_delete_by_drain(void *opaque)
|
|
|
357786 |
* If @detach_instead_of_delete is set, the BDS is not going to be
|
|
|
357786 |
* deleted but will only detach all of its children.
|
|
|
357786 |
*/
|
|
|
357786 |
-static void do_test_delete_by_drain(bool detach_instead_of_delete)
|
|
|
357786 |
+static void do_test_delete_by_drain(bool detach_instead_of_delete,
|
|
|
357786 |
+ enum drain_type drain_type)
|
|
|
357786 |
{
|
|
|
357786 |
BlockBackend *blk;
|
|
|
357786 |
BlockDriverState *bs, *child_bs, *null_bs;
|
|
|
357786 |
@@ -931,9 +932,23 @@ static void do_test_delete_by_drain(bool detach_instead_of_delete)
|
|
|
357786 |
* test_co_delete_by_drain() resuming. Thus, @bs will be deleted
|
|
|
357786 |
* and the coroutine will exit while this drain operation is still
|
|
|
357786 |
* in progress. */
|
|
|
357786 |
- bdrv_ref(child_bs);
|
|
|
357786 |
- bdrv_drain(child_bs);
|
|
|
357786 |
- bdrv_unref(child_bs);
|
|
|
357786 |
+ switch (drain_type) {
|
|
|
357786 |
+ case BDRV_DRAIN:
|
|
|
357786 |
+ bdrv_ref(child_bs);
|
|
|
357786 |
+ bdrv_drain(child_bs);
|
|
|
357786 |
+ bdrv_unref(child_bs);
|
|
|
357786 |
+ break;
|
|
|
357786 |
+ case BDRV_SUBTREE_DRAIN:
|
|
|
357786 |
+ /* Would have to ref/unref bs here for !detach_instead_of_delete, but
|
|
|
357786 |
+ * then the whole test becomes pointless because the graph changes
|
|
|
357786 |
+ * don't occur during the drain any more. */
|
|
|
357786 |
+ assert(detach_instead_of_delete);
|
|
|
357786 |
+ bdrv_subtree_drained_begin(bs);
|
|
|
357786 |
+ bdrv_subtree_drained_end(bs);
|
|
|
357786 |
+ break;
|
|
|
357786 |
+ default:
|
|
|
357786 |
+ g_assert_not_reached();
|
|
|
357786 |
+ }
|
|
|
357786 |
|
|
|
357786 |
while (!dbdd.done) {
|
|
|
357786 |
aio_poll(qemu_get_aio_context(), true);
|
|
|
357786 |
@@ -946,15 +961,19 @@ static void do_test_delete_by_drain(bool detach_instead_of_delete)
|
|
|
357786 |
}
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
-
|
|
|
357786 |
static void test_delete_by_drain(void)
|
|
|
357786 |
{
|
|
|
357786 |
- do_test_delete_by_drain(false);
|
|
|
357786 |
+ do_test_delete_by_drain(false, BDRV_DRAIN);
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
static void test_detach_by_drain(void)
|
|
|
357786 |
{
|
|
|
357786 |
- do_test_delete_by_drain(true);
|
|
|
357786 |
+ do_test_delete_by_drain(true, BDRV_DRAIN);
|
|
|
357786 |
+}
|
|
|
357786 |
+
|
|
|
357786 |
+static void test_detach_by_drain_subtree(void)
|
|
|
357786 |
+{
|
|
|
357786 |
+ do_test_delete_by_drain(true, BDRV_SUBTREE_DRAIN);
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
|
|
|
357786 |
@@ -1005,8 +1024,9 @@ int main(int argc, char **argv)
|
|
|
357786 |
g_test_add_func("/bdrv-drain/blockjob/drain_subtree",
|
|
|
357786 |
test_blockjob_drain_subtree);
|
|
|
357786 |
|
|
|
357786 |
- g_test_add_func("/bdrv-drain/deletion", test_delete_by_drain);
|
|
|
357786 |
- g_test_add_func("/bdrv-drain/detach", test_detach_by_drain);
|
|
|
357786 |
+ g_test_add_func("/bdrv-drain/deletion/drain", test_delete_by_drain);
|
|
|
357786 |
+ g_test_add_func("/bdrv-drain/detach/drain", test_detach_by_drain);
|
|
|
357786 |
+ g_test_add_func("/bdrv-drain/detach/drain_subtree", test_detach_by_drain_subtree);
|
|
|
357786 |
|
|
|
357786 |
ret = g_test_run();
|
|
|
357786 |
qemu_event_destroy(&done_event);
|
|
|
357786 |
--
|
|
|
357786 |
1.8.3.1
|
|
|
357786 |
|