cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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