From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dCnpl-0006dD-GJ for qemu-devel@nongnu.org; Mon, 22 May 2017 09:57:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dCnpk-0005QE-M6 for qemu-devel@nongnu.org; Mon, 22 May 2017 09:57:17 -0400 From: Stefan Hajnoczi Date: Mon, 22 May 2017 14:57:02 +0100 Message-Id: <20170522135704.842-3-stefanha@redhat.com> In-Reply-To: <20170522135704.842-1-stefanha@redhat.com> References: <20170522135704.842-1-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH v3 2/4] block: use BDRV_POLL_WHILE() in bdrv_rw_vmstate() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Paolo Bonzini , Kevin Wolf , Fam Zheng , Stefan Hajnoczi Calling aio_poll() directly may have been fine previously, but this is the future, man! The difference between an aio_poll() loop and BDRV_POLL_WHILE() is that BDRV_POLL_WHILE() releases the AioContext around aio_poll(). This allows the IOThread to run fd handlers or BHs to complete the request. Failure to release the AioContext causes deadlocks. Using BDRV_POLL_WHILE() partially fixes a 'savevm' hang with -object iothread. Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini --- block/io.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/block/io.c b/block/io.c index cc56e90..f0041cd 100644 --- a/block/io.c +++ b/block/io.c @@ -2031,9 +2031,7 @@ bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, Coroutine *co = qemu_coroutine_create(bdrv_co_rw_vmstate_entry, &data); bdrv_coroutine_enter(bs, co); - while (data.ret == -EINPROGRESS) { - aio_poll(bdrv_get_aio_context(bs), true); - } + BDRV_POLL_WHILE(bs, data.ret == -EINPROGRESS); return data.ret; } } -- 2.9.3