]> 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)
committerAurelien Jarno <aurelien@aurel32.net>
Thu, 27 May 2010 11:58:57 +0000 (13:58 +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>
(cherry picked from commit c53a7285b4377e91f30b7742c7e12c16d6bf86f0)

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);
 }