loop write in qemu_event_increment upon EINTR
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 2 Feb 2010 19:33:10 +0000 (20:33 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Wed, 10 Feb 2010 17:56:56 +0000 (11:56 -0600)
Same as what qemu-kvm does.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
vl.c

diff --git a/vl.c b/vl.c
index f98661f..29f2189 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -3217,8 +3217,12 @@ static void qemu_event_increment(void)
     if (io_thread_fd == -1)
         return;
 
-    ret = write(io_thread_fd, &byte, sizeof(byte));
-    if (ret < 0 && (errno != EINTR && errno != EAGAIN)) {
+    do {
+        ret = write(io_thread_fd, &byte, sizeof(byte));
+    } while (ret < 0 && errno == EINTR);
+
+    /* EAGAIN is fine, a read must be pending.  */
+    if (ret < 0 && errno != EAGAIN) {
         fprintf(stderr, "qemu_event_increment: write() filed: %s\n",
                 strerror(errno));
         exit (1);