timers: Createt TimersState and put all timers state there
[qemu] / aio.c
diff --git a/aio.c b/aio.c
index 11fbb6c..efc63fd 100644 (file)
--- a/aio.c
+++ b/aio.c
@@ -103,12 +103,16 @@ void qemu_aio_flush(void)
     do {
         ret = 0;
 
+       /*
+        * If there are pending emulated aio start them now so flush
+        * will be able to return 1.
+        */
+        qemu_aio_wait();
+
         LIST_FOREACH(node, &aio_handlers, node) {
             ret |= node->io_flush(node->opaque);
         }
-
-        qemu_aio_wait();
-    } while (ret > 0);
+    } while (qemu_bh_poll() || ret > 0);
 }
 
 void qemu_aio_wait(void)