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