Blame SOURCES/kvm-test-bdrv-drain-Test-bdrv_append-to-drained-node.patch

357786
From 55be3bf080a5b4768b88c1bc37b0867031add03d Mon Sep 17 00:00:00 2001
357786
From: Kevin Wolf <kwolf@redhat.com>
357786
Date: Fri, 14 Sep 2018 10:55:20 +0200
357786
Subject: [PATCH 29/49] test-bdrv-drain: Test bdrv_append() to drained node
357786
357786
RH-Author: Kevin Wolf <kwolf@redhat.com>
357786
Message-id: <20180914105540.18077-23-kwolf@redhat.com>
357786
Patchwork-id: 82174
357786
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 22/42] test-bdrv-drain: Test bdrv_append() to drained node
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
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
357786
(cherry picked from commit b994c5bc515fe611885113e7cfa7e87817bfd4e2)
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 | 43 +++++++++++++++++++++++++++++++++++++++++++
357786
 1 file changed, 43 insertions(+)
357786
357786
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
357786
index 1c8162f..9bcb3c7 100644
357786
--- a/tests/test-bdrv-drain.c
357786
+++ b/tests/test-bdrv-drain.c
357786
@@ -1245,6 +1245,47 @@ static void test_detach_by_driver_cb(void)
357786
     test_detach_indirect(false);
357786
 }
357786
 
357786
+static void test_append_to_drained(void)
357786
+{
357786
+    BlockBackend *blk;
357786
+    BlockDriverState *base, *overlay;
357786
+    BDRVTestState *base_s, *overlay_s;
357786
+
357786
+    blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
357786
+    base = bdrv_new_open_driver(&bdrv_test, "base", BDRV_O_RDWR, &error_abort);
357786
+    base_s = base->opaque;
357786
+    blk_insert_bs(blk, base, &error_abort);
357786
+
357786
+    overlay = bdrv_new_open_driver(&bdrv_test, "overlay", BDRV_O_RDWR,
357786
+                                   &error_abort);
357786
+    overlay_s = overlay->opaque;
357786
+
357786
+    do_drain_begin(BDRV_DRAIN, base);
357786
+    g_assert_cmpint(base->quiesce_counter, ==, 1);
357786
+    g_assert_cmpint(base_s->drain_count, ==, 1);
357786
+    g_assert_cmpint(base->in_flight, ==, 0);
357786
+
357786
+    /* Takes ownership of overlay, so we don't have to unref it later */
357786
+    bdrv_append(overlay, base, &error_abort);
357786
+    g_assert_cmpint(base->in_flight, ==, 0);
357786
+    g_assert_cmpint(overlay->in_flight, ==, 0);
357786
+
357786
+    g_assert_cmpint(base->quiesce_counter, ==, 1);
357786
+    g_assert_cmpint(base_s->drain_count, ==, 1);
357786
+    g_assert_cmpint(overlay->quiesce_counter, ==, 1);
357786
+    g_assert_cmpint(overlay_s->drain_count, ==, 1);
357786
+
357786
+    do_drain_end(BDRV_DRAIN, base);
357786
+
357786
+    g_assert_cmpint(base->quiesce_counter, ==, 0);
357786
+    g_assert_cmpint(base_s->drain_count, ==, 0);
357786
+    g_assert_cmpint(overlay->quiesce_counter, ==, 0);
357786
+    g_assert_cmpint(overlay_s->drain_count, ==, 0);
357786
+
357786
+    bdrv_unref(base);
357786
+    blk_unref(blk);
357786
+}
357786
+
357786
 int main(int argc, char **argv)
357786
 {
357786
     int ret;
357786
@@ -1303,6 +1344,8 @@ int main(int argc, char **argv)
357786
     g_test_add_func("/bdrv-drain/detach/parent_cb", test_detach_by_parent_cb);
357786
     g_test_add_func("/bdrv-drain/detach/driver_cb", test_detach_by_driver_cb);
357786
 
357786
+    g_test_add_func("/bdrv-drain/attach/drain", test_append_to_drained);
357786
+
357786
     ret = g_test_run();
357786
     qemu_event_destroy(&done_event);
357786
     return ret;
357786
-- 
357786
1.8.3.1
357786