Merge "Fixed infinite loop in qemu_aio_wait() affecting savevm."
diff --git a/aio-android.c b/aio-android.c
index 53f7a6d..2b67579 100644
--- a/aio-android.c
+++ b/aio-android.c
@@ -151,6 +151,11 @@
 
         walking_handlers = 0;
 
+        /* No AIO operations? Get us out of here */
+        if (!iolooper_has_operations(looper)) {
+            break;
+        }
+
         /* wait until next event */
         ret = iolooper_wait(looper, -1);
 
diff --git a/iolooper-select.c b/iolooper-select.c
index 74a5a3a..bf7ae8f 100644
--- a/iolooper-select.c
+++ b/iolooper-select.c
@@ -174,3 +174,9 @@
 {
     return FD_ISSET(fd, iol->writes_result);
 }
+
+int
+iolooper_has_operations( IoLooper* iol )
+{
+    return iolooper_fd_count(iol) > 0;
+}
diff --git a/iolooper.h b/iolooper.h
index ead3583..2822f71 100644
--- a/iolooper.h
+++ b/iolooper.h
@@ -21,5 +21,7 @@
 
 int        iolooper_is_read( IoLooper*  iol, int  fd );
 int        iolooper_is_write( IoLooper*  iol, int  fd );
+/* Returns 1 if this IoLooper has one or more file descriptor to interact with */
+int        iolooper_has_operations( IoLooper*  iol );
 
 #endif /* IOLOOPER_H */