diff options
author | Avi Kivity <avi@redhat.com> | 2010-05-16 14:59:57 +0300 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2010-05-27 13:58:57 +0200 |
commit | 74bcc51b993c7a5835ad6a8e35f8b79b7513f072 (patch) | |
tree | 87a7f52ef44040d5a3e4f20541bfe280d0211be9 | |
parent | 7e4f956056398f1dd3eb694177ef80cdab7c2f64 (diff) |
block: fix aio_flush segfaults for read-only protocols (e.g. curl)
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 <avi@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit c53a7285b4377e91f30b7742c7e12c16d6bf86f0)
-rw-r--r-- | aio.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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); } |