From: Paolo Bonzini <[email protected]>

Again, no need to loop if less than a full buffer is read, the next
read would return EAGAIN.

Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Avi Kivity <[email protected]>

diff --git a/qemu-kvm.c b/qemu-kvm.c
index 09eebef..b534d4e 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -2058,19 +2058,13 @@ static void sigfd_handler(void *opaque)
 static void io_thread_wakeup(void *opaque)
 {
     int fd = (unsigned long) opaque;
-    char buffer[4096];
-
-    /* Drain the pipe/(eventfd) */
-    while (1) {
-        ssize_t len;
+    ssize_t len;
+    char buffer[512];
 
+    /* Drain the notify pipe.  For eventfd, only 8 bytes will be read.  */
+    do {
         len = read(fd, buffer, sizeof(buffer));
-        if (len == -1 && errno == EINTR)
-            continue;
-
-        if (len <= 0)
-            break;
-    }
+    } while ((len == -1 && errno == EINTR) || len == sizeof(buffer));
 }
 
 int kvm_main_loop(void)
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to