cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-test-bdrv-drain-Test-node-deletion-in-subtree-recurs.patch

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