diff options
author | Kevin Wolf <kwolf@redhat.com> | 2019-02-08 13:18:49 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2019-02-25 15:03:19 +0100 |
commit | 247d2737715833525725d27e5cecf5840c62f900 (patch) | |
tree | ad07f64ba282540d74bb14466c98cbeaec02b89c /tests/test-bdrv-drain.c | |
parent | e64f25f30b80a71bd4e409ed518c39eeb5905166 (diff) |
test-bdrv-drain: AioContext switch in drained section
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests/test-bdrv-drain.c')
-rw-r--r-- | tests/test-bdrv-drain.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index ee1740ff06..1b1f6c17a5 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -1522,6 +1522,36 @@ static void test_append_to_drained(void) blk_unref(blk); } +static void test_set_aio_context(void) +{ + BlockDriverState *bs; + IOThread *a = iothread_new(); + IOThread *b = iothread_new(); + AioContext *ctx_a = iothread_get_aio_context(a); + AioContext *ctx_b = iothread_get_aio_context(b); + + bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR, + &error_abort); + + bdrv_drained_begin(bs); + bdrv_set_aio_context(bs, ctx_a); + + aio_context_acquire(ctx_a); + bdrv_drained_end(bs); + + bdrv_drained_begin(bs); + bdrv_set_aio_context(bs, ctx_b); + aio_context_release(ctx_a); + aio_context_acquire(ctx_b); + bdrv_set_aio_context(bs, qemu_get_aio_context()); + aio_context_release(ctx_b); + bdrv_drained_end(bs); + + bdrv_unref(bs); + iothread_join(a); + iothread_join(b); +} + int main(int argc, char **argv) { int ret; @@ -1603,6 +1633,8 @@ int main(int argc, char **argv) g_test_add_func("/bdrv-drain/attach/drain", test_append_to_drained); + g_test_add_func("/bdrv-drain/set_aio_context", test_set_aio_context); + ret = g_test_run(); qemu_event_destroy(&done_event); return ret; |