yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

b38b0f
From 7db4d6a7b791006e5b927d0a30f0106ce0c8b14d Mon Sep 17 00:00:00 2001
b38b0f
From: Kevin Wolf <kwolf@redhat.com>
b38b0f
Date: Wed, 14 Aug 2019 08:42:28 +0100
b38b0f
Subject: [PATCH 05/10] test-bdrv-drain: AioContext switch in drained section
b38b0f
b38b0f
RH-Author: Kevin Wolf <kwolf@redhat.com>
b38b0f
Message-id: <20190814084229.6458-5-kwolf@redhat.com>
b38b0f
Patchwork-id: 89965
b38b0f
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 4/5] test-bdrv-drain: AioContext switch in drained section
b38b0f
Bugzilla: 1716349
b38b0f
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
b38b0f
RH-Acked-by: Max Reitz <mreitz@redhat.com>
b38b0f
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
b38b0f
b38b0f
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
b38b0f
Reviewed-by: Eric Blake <eblake@redhat.com>
b38b0f
(cherry picked from commit 247d2737715833525725d27e5cecf5840c62f900)
b38b0f
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
b38b0f
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
b38b0f
---
b38b0f
 tests/test-bdrv-drain.c | 32 ++++++++++++++++++++++++++++++++
b38b0f
 1 file changed, 32 insertions(+)
b38b0f
b38b0f
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
b38b0f
index 8641b54..05c6f12 100644
b38b0f
--- a/tests/test-bdrv-drain.c
b38b0f
+++ b/tests/test-bdrv-drain.c
b38b0f
@@ -1521,6 +1521,36 @@ static void test_append_to_drained(void)
b38b0f
     blk_unref(blk);
b38b0f
 }
b38b0f
 
b38b0f
+static void test_set_aio_context(void)
b38b0f
+{
b38b0f
+    BlockDriverState *bs;
b38b0f
+    IOThread *a = iothread_new();
b38b0f
+    IOThread *b = iothread_new();
b38b0f
+    AioContext *ctx_a = iothread_get_aio_context(a);
b38b0f
+    AioContext *ctx_b = iothread_get_aio_context(b);
b38b0f
+
b38b0f
+    bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR,
b38b0f
+                              &error_abort);
b38b0f
+
b38b0f
+    bdrv_drained_begin(bs);
b38b0f
+    bdrv_set_aio_context(bs, ctx_a);
b38b0f
+
b38b0f
+    aio_context_acquire(ctx_a);
b38b0f
+    bdrv_drained_end(bs);
b38b0f
+
b38b0f
+    bdrv_drained_begin(bs);
b38b0f
+    bdrv_set_aio_context(bs, ctx_b);
b38b0f
+    aio_context_release(ctx_a);
b38b0f
+    aio_context_acquire(ctx_b);
b38b0f
+    bdrv_set_aio_context(bs, qemu_get_aio_context());
b38b0f
+    aio_context_release(ctx_b);
b38b0f
+    bdrv_drained_end(bs);
b38b0f
+
b38b0f
+    bdrv_unref(bs);
b38b0f
+    iothread_join(a);
b38b0f
+    iothread_join(b);
b38b0f
+}
b38b0f
+
b38b0f
 int main(int argc, char **argv)
b38b0f
 {
b38b0f
     int ret;
b38b0f
@@ -1602,6 +1632,8 @@ int main(int argc, char **argv)
b38b0f
 
b38b0f
     g_test_add_func("/bdrv-drain/attach/drain", test_append_to_drained);
b38b0f
 
b38b0f
+    g_test_add_func("/bdrv-drain/set_aio_context", test_set_aio_context);
b38b0f
+
b38b0f
     ret = g_test_run();
b38b0f
     qemu_event_destroy(&done_event);
b38b0f
     return ret;
b38b0f
-- 
b38b0f
1.8.3.1
b38b0f