From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=42903 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ODcVo-0001BY-1q for qemu-devel@nongnu.org; Sun, 16 May 2010 08:00:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ODcVl-0000Qk-9m for qemu-devel@nongnu.org; Sun, 16 May 2010 08:00:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41051) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ODcVk-0000QS-U9 for qemu-devel@nongnu.org; Sun, 16 May 2010 08:00:01 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4GBxx7m025061 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 16 May 2010 08:00:00 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4GBxwOD012304 for ; Sun, 16 May 2010 07:59:59 -0400 From: Avi Kivity Date: Sun, 16 May 2010 14:59:57 +0300 Message-Id: <1274011197-26196-1-git-send-email-avi@redhat.com> Subject: [Qemu-devel] [PATCH] 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: Kevin Wolf Cc: qemu-devel@nongnu.org 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 --- 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.7.0.4