[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 14/19] test-bdrv-drain: Test behaviour in corout
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 14/19] test-bdrv-drain: Test behaviour in coroutine context |
Date: |
Wed, 20 Dec 2017 11:53:25 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 |
On 20/12/2017 11:34, Kevin Wolf wrote:
> If bdrv_do_drained_begin/end() are called in coroutine context, they
> first use a BH to get out of the coroutine context. Call some existing
> tests again from a coroutine to cover this code path.
>
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
> tests/test-bdrv-drain.c | 51
> +++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 51 insertions(+)
>
> diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
> index c00d96bb2f..a1e5693f33 100644
> --- a/tests/test-bdrv-drain.c
> +++ b/tests/test-bdrv-drain.c
> @@ -188,6 +188,30 @@ static void test_drv_cb_drain_subtree(void)
> test_drv_cb_common(BDRV_SUBTREE_DRAIN, true);
> }
>
> +static coroutine_fn void test_drv_cb_coroutine_entry(void *opaque)
> +{
> + bool *done = opaque;
> +
> + // XXX bdrv_drain_all() doesn't work in coroutine context
> + //test_drv_cb_drain_all();
> + test_drv_cb_drain();
> + test_drv_cb_drain_subtree();
> +
> + *done = true;
> +}
> +
> +static void test_drv_cb_coroutine(void)
> +{
> + Coroutine *co;
> + bool done;
> +
> + co = qemu_coroutine_create(test_drv_cb_coroutine_entry, &done);
> + qemu_coroutine_enter(co);
> + while (!done) {
> + aio_poll(qemu_get_aio_context(), true);
> + }
> +}
> +
> static void test_quiesce_common(enum drain_type drain_type, bool recursive)
> {
> BlockBackend *blk;
> @@ -235,6 +259,30 @@ static void test_quiesce_drain_subtree(void)
> test_quiesce_common(BDRV_SUBTREE_DRAIN, true);
> }
>
> +static coroutine_fn void test_quiesce_coroutine_entry(void *opaque)
> +{
> + bool *done = opaque;
> +
> + // XXX bdrv_drain_all() doesn't work in coroutine context
> + //test_quiesce_drain_all();
> + test_quiesce_drain();
> + test_quiesce_drain_subtree();
> +
> + *done = true;
> +}
> +
> +static void test_quiesce_coroutine(void)
> +{
> + Coroutine *co;
> + bool done;
> +
> + co = qemu_coroutine_create(test_quiesce_coroutine_entry, &done);
> + qemu_coroutine_enter(co);
> + while (!done) {
> + aio_poll(qemu_get_aio_context(), true);
> + }
> +}
> +
> static void test_nested(void)
> {
> BlockBackend *blk;
> @@ -421,11 +469,14 @@ int main(int argc, char **argv)
> g_test_add_func("/bdrv-drain/driver-cb/drain", test_drv_cb_drain);
> g_test_add_func("/bdrv-drain/driver-cb/drain_subtree",
> test_drv_cb_drain_subtree);
> + g_test_add_func("/bdrv-drain/driver-cb/coroutine",
> test_drv_cb_coroutine);
> +
>
> g_test_add_func("/bdrv-drain/quiesce/drain_all", test_quiesce_drain_all);
> g_test_add_func("/bdrv-drain/quiesce/drain", test_quiesce_drain);
> g_test_add_func("/bdrv-drain/quiesce/drain_subtree",
> test_quiesce_drain_subtree);
> + g_test_add_func("/bdrv-drain/quiesce/coroutine", test_quiesce_coroutine);
Maybe split the two sub-tests of test_{drv_cb,quiesce}_coroutine into
separate g_test_add_func?
Thanks,
Paolo
> g_test_add_func("/bdrv-drain/nested", test_nested);
>
>
- [Qemu-devel] [PATCH 04/19] test-bdrv-drain: Test callback for bdrv_drain, (continued)
- [Qemu-devel] [PATCH 04/19] test-bdrv-drain: Test callback for bdrv_drain, Kevin Wolf, 2017/12/20
- [Qemu-devel] [PATCH 05/19] test-bdrv-drain: Test bs->quiesce_counter, Kevin Wolf, 2017/12/20
- [Qemu-devel] [PATCH 08/19] block: Don't block_job_pause_all() in bdrv_drain_all(), Kevin Wolf, 2017/12/20
- [Qemu-devel] [PATCH 09/19] block: Nested drain_end must still call callbacks, Kevin Wolf, 2017/12/20
- [Qemu-devel] [PATCH 07/19] test-bdrv-drain: Test drain vs. block jobs, Kevin Wolf, 2017/12/20
- [Qemu-devel] [PATCH 06/19] blockjob: Pause job on draining any job BDS, Kevin Wolf, 2017/12/20
- [Qemu-devel] [PATCH 10/19] test-bdrv-drain: Test nested drain sections, Kevin Wolf, 2017/12/20
- [Qemu-devel] [PATCH 11/19] block: Don't notify parents in drain call chain, Kevin Wolf, 2017/12/20
- [Qemu-devel] [PATCH 12/19] block: Add bdrv_subtree_drained_begin/end(), Kevin Wolf, 2017/12/20
- [Qemu-devel] [PATCH 14/19] test-bdrv-drain: Test behaviour in coroutine context, Kevin Wolf, 2017/12/20
- Re: [Qemu-devel] [PATCH 14/19] test-bdrv-drain: Test behaviour in coroutine context,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 13/19] test-bdrv-drain: Tests for bdrv_subtree_drain, Kevin Wolf, 2017/12/20
- [Qemu-devel] [PATCH 17/19] test-bdrv-drain: Test graph changes in drained section, Kevin Wolf, 2017/12/20
- [Qemu-devel] [PATCH 15/19] test-bdrv-drain: Recursive draining with multiple parents, Kevin Wolf, 2017/12/20
- [Qemu-devel] [PATCH 16/19] block: Allow graph changes in subtree drained section, Kevin Wolf, 2017/12/20
[Qemu-devel] [PATCH 18/19] commit: Simplify reopen of base, Kevin Wolf, 2017/12/20