|
|
ae23c9 |
From 784ce8c1c23db1b654e85804e6d19508429ce5b5 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Date: Wed, 10 Oct 2018 20:21:49 +0100
|
|
|
ae23c9 |
Subject: [PATCH 23/49] test-bdrv-drain: Test graph changes in drain_all
|
|
|
ae23c9 |
section
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Message-id: <20181010202213.7372-11-kwolf@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 82600
|
|
|
ae23c9 |
O-Subject: [RHEL-8 qemu-kvm PATCH 20/44] test-bdrv-drain: Test graph changes in drain_all section
|
|
|
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 |
This tests both adding and remove a node between bdrv_drain_all_begin()
|
|
|
ae23c9 |
and bdrv_drain_all_end(), and enabled the existing detach test for
|
|
|
ae23c9 |
drain_all.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit 19f7a7e574a099dca13120441fbe723cea9c1dc2)
|
|
|
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 | 75 +++++++++++++++++++++++++++++++++++++++++++++++--
|
|
|
ae23c9 |
1 file changed, 73 insertions(+), 2 deletions(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
|
|
|
ae23c9 |
index c4aa913..1c8162f 100644
|
|
|
ae23c9 |
--- a/tests/test-bdrv-drain.c
|
|
|
ae23c9 |
+++ b/tests/test-bdrv-drain.c
|
|
|
ae23c9 |
@@ -452,7 +452,7 @@ static void test_multiparent(void)
|
|
|
ae23c9 |
blk_unref(blk_b);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
-static void test_graph_change(void)
|
|
|
ae23c9 |
+static void test_graph_change_drain_subtree(void)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
BlockBackend *blk_a, *blk_b;
|
|
|
ae23c9 |
BlockDriverState *bs_a, *bs_b, *backing;
|
|
|
ae23c9 |
@@ -531,6 +531,63 @@ static void test_graph_change(void)
|
|
|
ae23c9 |
blk_unref(blk_b);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+static void test_graph_change_drain_all(void)
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ BlockBackend *blk_a, *blk_b;
|
|
|
ae23c9 |
+ BlockDriverState *bs_a, *bs_b;
|
|
|
ae23c9 |
+ BDRVTestState *a_s, *b_s;
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ /* Create node A with a BlockBackend */
|
|
|
ae23c9 |
+ blk_a = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
|
|
ae23c9 |
+ bs_a = bdrv_new_open_driver(&bdrv_test, "test-node-a", BDRV_O_RDWR,
|
|
|
ae23c9 |
+ &error_abort);
|
|
|
ae23c9 |
+ a_s = bs_a->opaque;
|
|
|
ae23c9 |
+ blk_insert_bs(blk_a, bs_a, &error_abort);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ g_assert_cmpint(bs_a->quiesce_counter, ==, 0);
|
|
|
ae23c9 |
+ g_assert_cmpint(a_s->drain_count, ==, 0);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ /* Call bdrv_drain_all_begin() */
|
|
|
ae23c9 |
+ bdrv_drain_all_begin();
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ g_assert_cmpint(bs_a->quiesce_counter, ==, 1);
|
|
|
ae23c9 |
+ g_assert_cmpint(a_s->drain_count, ==, 1);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ /* Create node B with a BlockBackend */
|
|
|
ae23c9 |
+ blk_b = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
|
|
ae23c9 |
+ bs_b = bdrv_new_open_driver(&bdrv_test, "test-node-b", BDRV_O_RDWR,
|
|
|
ae23c9 |
+ &error_abort);
|
|
|
ae23c9 |
+ b_s = bs_b->opaque;
|
|
|
ae23c9 |
+ blk_insert_bs(blk_b, bs_b, &error_abort);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ g_assert_cmpint(bs_a->quiesce_counter, ==, 1);
|
|
|
ae23c9 |
+ g_assert_cmpint(bs_b->quiesce_counter, ==, 1);
|
|
|
ae23c9 |
+ g_assert_cmpint(a_s->drain_count, ==, 1);
|
|
|
ae23c9 |
+ g_assert_cmpint(b_s->drain_count, ==, 1);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ /* Unref and finally delete node A */
|
|
|
ae23c9 |
+ blk_unref(blk_a);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ g_assert_cmpint(bs_a->quiesce_counter, ==, 1);
|
|
|
ae23c9 |
+ g_assert_cmpint(bs_b->quiesce_counter, ==, 1);
|
|
|
ae23c9 |
+ g_assert_cmpint(a_s->drain_count, ==, 1);
|
|
|
ae23c9 |
+ g_assert_cmpint(b_s->drain_count, ==, 1);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ bdrv_unref(bs_a);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ g_assert_cmpint(bs_b->quiesce_counter, ==, 1);
|
|
|
ae23c9 |
+ g_assert_cmpint(b_s->drain_count, ==, 1);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ /* End the drained section */
|
|
|
ae23c9 |
+ bdrv_drain_all_end();
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ g_assert_cmpint(bs_b->quiesce_counter, ==, 0);
|
|
|
ae23c9 |
+ g_assert_cmpint(b_s->drain_count, ==, 0);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ bdrv_unref(bs_b);
|
|
|
ae23c9 |
+ blk_unref(blk_b);
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
struct test_iothread_data {
|
|
|
ae23c9 |
BlockDriverState *bs;
|
|
|
ae23c9 |
enum drain_type drain_type;
|
|
|
ae23c9 |
@@ -966,6 +1023,10 @@ static void do_test_delete_by_drain(bool detach_instead_of_delete,
|
|
|
ae23c9 |
bdrv_subtree_drained_begin(bs);
|
|
|
ae23c9 |
bdrv_subtree_drained_end(bs);
|
|
|
ae23c9 |
break;
|
|
|
ae23c9 |
+ case BDRV_DRAIN_ALL:
|
|
|
ae23c9 |
+ bdrv_drain_all_begin();
|
|
|
ae23c9 |
+ bdrv_drain_all_end();
|
|
|
ae23c9 |
+ break;
|
|
|
ae23c9 |
default:
|
|
|
ae23c9 |
g_assert_not_reached();
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
@@ -986,6 +1047,11 @@ static void test_delete_by_drain(void)
|
|
|
ae23c9 |
do_test_delete_by_drain(false, BDRV_DRAIN);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+static void test_detach_by_drain_all(void)
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ do_test_delete_by_drain(true, BDRV_DRAIN_ALL);
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
static void test_detach_by_drain(void)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
do_test_delete_by_drain(true, BDRV_DRAIN);
|
|
|
ae23c9 |
@@ -1214,7 +1280,11 @@ int main(int argc, char **argv)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
g_test_add_func("/bdrv-drain/nested", test_nested);
|
|
|
ae23c9 |
g_test_add_func("/bdrv-drain/multiparent", test_multiparent);
|
|
|
ae23c9 |
- g_test_add_func("/bdrv-drain/graph-change", test_graph_change);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ g_test_add_func("/bdrv-drain/graph-change/drain_subtree",
|
|
|
ae23c9 |
+ test_graph_change_drain_subtree);
|
|
|
ae23c9 |
+ g_test_add_func("/bdrv-drain/graph-change/drain_all",
|
|
|
ae23c9 |
+ test_graph_change_drain_all);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
g_test_add_func("/bdrv-drain/iothread/drain_all", test_iothread_drain_all);
|
|
|
ae23c9 |
g_test_add_func("/bdrv-drain/iothread/drain", test_iothread_drain);
|
|
|
ae23c9 |
@@ -1227,6 +1297,7 @@ int main(int argc, char **argv)
|
|
|
ae23c9 |
test_blockjob_drain_subtree);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
g_test_add_func("/bdrv-drain/deletion/drain", test_delete_by_drain);
|
|
|
ae23c9 |
+ g_test_add_func("/bdrv-drain/detach/drain_all", test_detach_by_drain_all);
|
|
|
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 |
g_test_add_func("/bdrv-drain/detach/parent_cb", test_detach_by_parent_cb);
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|