yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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