From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WfsOH-00005q-Py for qemu-devel@nongnu.org; Thu, 01 May 2014 10:55:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WfsO3-0003iv-55 for qemu-devel@nongnu.org; Thu, 01 May 2014 10:55:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59426) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WfsO2-0003in-Th for qemu-devel@nongnu.org; Thu, 01 May 2014 10:54:59 -0400 From: Stefan Hajnoczi Date: Thu, 1 May 2014 16:54:26 +0200 Message-Id: <1398956086-20171-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1398956086-20171-1-git-send-email-stefanha@redhat.com> References: <1398956086-20171-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH 02/22] block: acquire AioContext in bdrv_close_all() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , "Shergill, Gurinder" , "Vinod, Chegu" , Stefan Hajnoczi bdrv_close_all() closes all BlockDriverState instances. It is called from vl.c:main() and qemu-nbd when shutting down. Some BlockDriverState instances may be running in another AioContext. Make sure to acquire the AioContext before closing the BlockDriverState. This will protect against race conditions once virtio-blk data-plane is using the BlockDriverState from another AioContext event loop. Signed-off-by: Stefan Hajnoczi --- block.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block.c b/block.c index 94999e5..9381918 100644 --- a/block.c +++ b/block.c @@ -1755,7 +1755,11 @@ void bdrv_close_all(void) BlockDriverState *bs; QTAILQ_FOREACH(bs, &bdrv_states, device_list) { + AioContext *aio_context = bdrv_get_aio_context(bs); + + aio_context_acquire(aio_context); bdrv_close(bs); + aio_context_release(aio_context); } } -- 1.9.0