Received: from [140.186.70.92] (port=33265 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OF5Wz-0000fC-08 for qemu-devel@nongnu.org; Thu, 20 May 2010 09:11:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OF5Wm-00071K-N2 for qemu-devel@nongnu.org; Thu, 20 May 2010 09:11:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47785) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OF5Wm-00070k-FO for qemu-devel@nongnu.org; Thu, 20 May 2010 09:11:08 -0400 From: Kevin Wolf Date: Thu, 20 May 2010 15:10:36 +0200 Message-Id: <1274361043-25862-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1274361043-25862-1-git-send-email-kwolf@redhat.com> References: <1274361043-25862-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 1/8] block: fix aio_flush segfaults for read-only protocols (e.g. curl) List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Avi Kivity Not all block format drivers expose an io_flush method (reasonable for read-only protocols), so calling io_flush there will immediately segfault. Fix by checking for the method's existence before calling it. Signed-off-by: Avi Kivity Signed-off-by: Kevin Wolf --- aio.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/aio.c b/aio.c index f164a47..2f08655 100644 --- a/aio.c +++ b/aio.c @@ -113,7 +113,9 @@ void qemu_aio_flush(void) qemu_aio_wait(); QLIST_FOREACH(node, &aio_handlers, node) { - ret |= node->io_flush(node->opaque); + if (node->io_flush) { + ret |= node->io_flush(node->opaque); + } } } while (qemu_bh_poll() || ret > 0); } -- 1.6.6.1