Patchwork [2/3] loop write in qemu_event_increment upon EINTR

login
register
mail settings
Submitter Paolo Bonzini
Date Feb. 2, 2010, 7:33 p.m.
Message ID <1265139191-13568-3-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/44305/
State New
Headers show

Comments

Paolo Bonzini - Feb. 2, 2010, 7:33 p.m.
Same as what qemu-kvm does.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 vl.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

Patch

diff --git a/vl.c b/vl.c
index 46c1118..f150eca 100644
--- a/vl.c
+++ b/vl.c
@@ -3198,8 +3198,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);