Blame SOURCES/kvm-test-bdrv-drain-AioContext-switch-in-drained-section.patch

7711c0
From ed61540140ae22f897f15846a359dc11a0a0b027 Mon Sep 17 00:00:00 2001
7711c0
From: Kevin Wolf <kwolf@redhat.com>
7711c0
Date: Fri, 1 Mar 2019 14:27:46 +0100
7711c0
Subject: [PATCH 4/9] test-bdrv-drain: AioContext switch in drained section
7711c0
7711c0
RH-Author: Kevin Wolf <kwolf@redhat.com>
7711c0
Message-id: <20190301142747.12251-5-kwolf@redhat.com>
7711c0
Patchwork-id: 84766
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 4/5] test-bdrv-drain: AioContext switch in drained section
7711c0
Bugzilla: 1671173
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
7711c0
RH-Acked-by: John Snow <jsnow@redhat.com>
7711c0
7711c0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7711c0
Reviewed-by: Eric Blake <eblake@redhat.com>
7711c0
(cherry picked from commit 247d2737715833525725d27e5cecf5840c62f900)
7711c0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 tests/test-bdrv-drain.c | 32 ++++++++++++++++++++++++++++++++
7711c0
 1 file changed, 32 insertions(+)
7711c0
7711c0
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
7711c0
index 8641b54..05c6f12 100644
7711c0
--- a/tests/test-bdrv-drain.c
7711c0
+++ b/tests/test-bdrv-drain.c
7711c0
@@ -1521,6 +1521,36 @@ static void test_append_to_drained(void)
7711c0
     blk_unref(blk);
7711c0
 }
7711c0
 
7711c0
+static void test_set_aio_context(void)
7711c0
+{
7711c0
+    BlockDriverState *bs;
7711c0
+    IOThread *a = iothread_new();
7711c0
+    IOThread *b = iothread_new();
7711c0
+    AioContext *ctx_a = iothread_get_aio_context(a);
7711c0
+    AioContext *ctx_b = iothread_get_aio_context(b);
7711c0
+
7711c0
+    bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR,
7711c0
+                              &error_abort);
7711c0
+
7711c0
+    bdrv_drained_begin(bs);
7711c0
+    bdrv_set_aio_context(bs, ctx_a);
7711c0
+
7711c0
+    aio_context_acquire(ctx_a);
7711c0
+    bdrv_drained_end(bs);
7711c0
+
7711c0
+    bdrv_drained_begin(bs);
7711c0
+    bdrv_set_aio_context(bs, ctx_b);
7711c0
+    aio_context_release(ctx_a);
7711c0
+    aio_context_acquire(ctx_b);
7711c0
+    bdrv_set_aio_context(bs, qemu_get_aio_context());
7711c0
+    aio_context_release(ctx_b);
7711c0
+    bdrv_drained_end(bs);
7711c0
+
7711c0
+    bdrv_unref(bs);
7711c0
+    iothread_join(a);
7711c0
+    iothread_join(b);
7711c0
+}
7711c0
+
7711c0
 int main(int argc, char **argv)
7711c0
 {
7711c0
     int ret;
7711c0
@@ -1602,6 +1632,8 @@ int main(int argc, char **argv)
7711c0
 
7711c0
     g_test_add_func("/bdrv-drain/attach/drain", test_append_to_drained);
7711c0
 
7711c0
+    g_test_add_func("/bdrv-drain/set_aio_context", test_set_aio_context);
7711c0
+
7711c0
     ret = g_test_run();
7711c0
     qemu_event_destroy(&done_event);
7711c0
     return ret;
7711c0
-- 
7711c0
1.8.3.1
7711c0