[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 16/24] test-block-iothread: Test AioContext propagati
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 16/24] test-block-iothread: Test AioContext propagation for block jobs |
Date: |
Mon, 20 May 2019 18:14:45 +0200 |
Signed-off-by: Kevin Wolf <address@hidden>
---
tests/test-block-iothread.c | 71 +++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c
index 938831c9bd..59f692892e 100644
--- a/tests/test-block-iothread.c
+++ b/tests/test-block-iothread.c
@@ -588,6 +588,76 @@ static void test_propagate_diamond(void)
bdrv_unref(bs_a);
}
+static void test_propagate_mirror(void)
+{
+ IOThread *iothread = iothread_new();
+ AioContext *ctx = iothread_get_aio_context(iothread);
+ AioContext *main_ctx = qemu_get_aio_context();
+ BlockDriverState *src, *target;
+ BlockBackend *blk;
+ Job *job;
+ Error *local_err = NULL;
+
+ /* Create src and target*/
+ src = bdrv_new_open_driver(&bdrv_test, "src", BDRV_O_RDWR, &error_abort);
+ target = bdrv_new_open_driver(&bdrv_test, "target", BDRV_O_RDWR,
+ &error_abort);
+
+ /* Start a mirror job */
+ mirror_start("job0", src, target, NULL, JOB_DEFAULT, 0, 0, 0,
+ MIRROR_SYNC_MODE_NONE, MIRROR_OPEN_BACKING_CHAIN,
+ BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
+ false, "filter_node", MIRROR_COPY_MODE_BACKGROUND,
+ &error_abort);
+ job = job_get("job0");
+
+ /* Change the AioContext of src */
+ bdrv_try_set_aio_context(src, ctx, &error_abort);
+ g_assert(bdrv_get_aio_context(src) == ctx);
+ g_assert(bdrv_get_aio_context(target) == ctx);
+ g_assert(job->aio_context == ctx);
+
+ /* Change the AioContext of target */
+ aio_context_acquire(ctx);
+ bdrv_try_set_aio_context(target, main_ctx, &error_abort);
+ aio_context_release(ctx);
+ g_assert(bdrv_get_aio_context(src) == main_ctx);
+ g_assert(bdrv_get_aio_context(target) == main_ctx);
+
+ /* With a BlockBackend on src, changing target must fail */
+ blk = blk_new(0, BLK_PERM_ALL);
+ blk_insert_bs(blk, src, &error_abort);
+
+ bdrv_try_set_aio_context(target, ctx, &local_err);
+ g_assert(local_err);
+ error_free(local_err);
+
+ g_assert(blk_get_aio_context(blk) == main_ctx);
+ g_assert(bdrv_get_aio_context(src) == main_ctx);
+ g_assert(bdrv_get_aio_context(target) == main_ctx);
+
+ /* ...unless we explicitly allow it */
+ aio_context_acquire(ctx);
+ blk_set_allow_aio_context_change(blk, true);
+ bdrv_try_set_aio_context(target, ctx, &error_abort);
+ aio_context_release(ctx);
+
+ g_assert(blk_get_aio_context(blk) == ctx);
+ g_assert(bdrv_get_aio_context(src) == ctx);
+ g_assert(bdrv_get_aio_context(target) == ctx);
+
+ job_cancel_sync_all();
+
+ aio_context_acquire(ctx);
+ blk_set_aio_context(blk, main_ctx);
+ bdrv_try_set_aio_context(target, main_ctx, &error_abort);
+ aio_context_release(ctx);
+
+ blk_unref(blk);
+ bdrv_unref(src);
+ bdrv_unref(target);
+}
+
int main(int argc, char **argv)
{
int i;
@@ -605,6 +675,7 @@ int main(int argc, char **argv)
g_test_add_func("/attach/blockjob", test_attach_blockjob);
g_test_add_func("/propagate/basic", test_propagate_basic);
g_test_add_func("/propagate/diamond", test_propagate_diamond);
+ g_test_add_func("/propagate/mirror", test_propagate_mirror);
return g_test_run();
}
--
2.20.1
- [Qemu-block] [PULL 04/24] qmp: forbid qmp_cont in RUN_STATE_FINISH_MIGRATE, (continued)
- [Qemu-block] [PULL 04/24] qmp: forbid qmp_cont in RUN_STATE_FINISH_MIGRATE, Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 03/24] block: Use BDRV_REQUEST_MAX_BYTES instead of BDRV_REQUEST_MAX_SECTORS, Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 01/24] block/file-posix: Truncate in xfs_write_zeroes(), Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 02/24] qcow2: Define and use QCOW2_COMPRESSED_SECTOR_SIZE, Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 09/24] block: Move recursion to bdrv_set_aio_context(), Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 12/24] block: Implement .(can_)set_aio_ctx for BlockBackend, Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 07/24] block: Add bdrv_try_set_aio_context(), Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 05/24] iotest: fix 169: do not run qmp_cont in RUN_STATE_FINISH_MIGRATE, Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 10/24] block: Propagate AioContext change to parents, Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 11/24] test-block-iothread: Test AioContext propagation through the tree, Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 16/24] test-block-iothread: Test AioContext propagation for block jobs,
Kevin Wolf <=
- [Qemu-block] [PULL 13/24] block: Add blk_set_allow_aio_context_change(), Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 08/24] block: Make bdrv_attach/detach_aio_context() static, Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 15/24] blockjob: Remove AioContext notifiers, Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 14/24] blockjob: Propagate AioContext change to all job nodes, Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 17/24] block/file-posix: Unaligned O_DIRECT block-status, Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 22/24] iotests.py: Let assert_qmp() accept an array, Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 18/24] iotests: Test unaligned raw images with O_DIRECT, Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 24/24] iotests: Make 245 faster and more reliable, Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 21/24] block: Improve "Block node is read-only" message, Kevin Wolf, 2019/05/20
- [Qemu-block] [PULL 19/24] qemu-img.texi: Be specific about JSON object types, Kevin Wolf, 2019/05/20