]> git.proxmox.com Git - qemu.git/commitdiff
block: fix aio_flush segfaults for read-only protocols (e.g. curl)
authorAvi Kivity <avi@redhat.com>
Sun, 16 May 2010 11:59:57 +0000 (14:59 +0300)
committerKevin Wolf <kwolf@redhat.com>
Fri, 21 May 2010 09:49:18 +0000 (11:49 +0200)
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>
aio.c

diff --git a/aio.c b/aio.c
index f164a478c5ed86dd09e2fe9052756cb049cb7b18..2f086557b6673fd1a6d8b7fe8ff322c9a53bbf18 100644 (file)
--- 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);
 }