qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-block] [PATCH 14/19] test-bdrv-drain: Test behaviour in coroutine


From: Kevin Wolf
Subject: [Qemu-block] [PATCH 14/19] test-bdrv-drain: Test behaviour in coroutine context
Date: Wed, 20 Dec 2017 11:34:07 +0100

If bdrv_do_drained_begin/end() are called in coroutine context, they
first use a BH to get out of the coroutine context. Call some existing
tests again from a coroutine to cover this code path.

Signed-off-by: Kevin Wolf <address@hidden>
---
 tests/test-bdrv-drain.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
index c00d96bb2f..a1e5693f33 100644
--- a/tests/test-bdrv-drain.c
+++ b/tests/test-bdrv-drain.c
@@ -188,6 +188,30 @@ static void test_drv_cb_drain_subtree(void)
     test_drv_cb_common(BDRV_SUBTREE_DRAIN, true);
 }
 
+static coroutine_fn void test_drv_cb_coroutine_entry(void *opaque)
+{
+    bool *done = opaque;
+
+    // XXX bdrv_drain_all() doesn't work in coroutine context
+    //test_drv_cb_drain_all();
+    test_drv_cb_drain();
+    test_drv_cb_drain_subtree();
+
+    *done = true;
+}
+
+static void test_drv_cb_coroutine(void)
+{
+    Coroutine *co;
+    bool done;
+
+    co = qemu_coroutine_create(test_drv_cb_coroutine_entry, &done);
+    qemu_coroutine_enter(co);
+    while (!done) {
+        aio_poll(qemu_get_aio_context(), true);
+    }
+}
+
 static void test_quiesce_common(enum drain_type drain_type, bool recursive)
 {
     BlockBackend *blk;
@@ -235,6 +259,30 @@ static void test_quiesce_drain_subtree(void)
     test_quiesce_common(BDRV_SUBTREE_DRAIN, true);
 }
 
+static coroutine_fn void test_quiesce_coroutine_entry(void *opaque)
+{
+    bool *done = opaque;
+
+    // XXX bdrv_drain_all() doesn't work in coroutine context
+    //test_quiesce_drain_all();
+    test_quiesce_drain();
+    test_quiesce_drain_subtree();
+
+    *done = true;
+}
+
+static void test_quiesce_coroutine(void)
+{
+    Coroutine *co;
+    bool done;
+
+    co = qemu_coroutine_create(test_quiesce_coroutine_entry, &done);
+    qemu_coroutine_enter(co);
+    while (!done) {
+        aio_poll(qemu_get_aio_context(), true);
+    }
+}
+
 static void test_nested(void)
 {
     BlockBackend *blk;
@@ -421,11 +469,14 @@ int main(int argc, char **argv)
     g_test_add_func("/bdrv-drain/driver-cb/drain", test_drv_cb_drain);
     g_test_add_func("/bdrv-drain/driver-cb/drain_subtree",
                     test_drv_cb_drain_subtree);
+    g_test_add_func("/bdrv-drain/driver-cb/coroutine", test_drv_cb_coroutine);
+
 
     g_test_add_func("/bdrv-drain/quiesce/drain_all", test_quiesce_drain_all);
     g_test_add_func("/bdrv-drain/quiesce/drain", test_quiesce_drain);
     g_test_add_func("/bdrv-drain/quiesce/drain_subtree",
                     test_quiesce_drain_subtree);
+    g_test_add_func("/bdrv-drain/quiesce/coroutine", test_quiesce_coroutine);
 
     g_test_add_func("/bdrv-drain/nested", test_nested);
 
-- 
2.13.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]