{
     sigset_t set;
     int nb_sigs;
+
+#ifndef QEMU_TOOL
+    if (qemu_bh_poll())
+        return;
+#endif
     sigemptyset(&set);
     sigaddset(&set, aio_sig_num);
     sigwait(&set, &nb_sigs);
 
     return bh;
 }
 
-void qemu_bh_poll(void)
+int qemu_bh_poll(void)
 {
     QEMUBH *bh, **pbh;
+    int ret;
 
+    ret = 0;
     for(;;) {
         pbh = &first_bh;
         bh = *pbh;
         if (!bh)
             break;
+        ret = 1;
         *pbh = bh->next;
         bh->scheduled = 0;
         bh->cb(bh->opaque);
     }
+    return ret;
 }
 
 void qemu_bh_schedule(QEMUBH *bh)
 
 void qemu_bh_schedule(QEMUBH *bh);
 void qemu_bh_cancel(QEMUBH *bh);
 void qemu_bh_delete(QEMUBH *bh);
-void qemu_bh_poll(void);
+int qemu_bh_poll(void);
 
 /* block.c */
 typedef struct BlockDriverState BlockDriverState;