]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
exec-migration: handle EINTR in popen_get_buffer()
authorUri Lublin <uril@redhat.com>
Mon, 8 Jun 2009 16:27:21 +0000 (19:27 +0300)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 16 Jun 2009 22:11:13 +0000 (17:11 -0500)
Sometimes, upon interrupt, fread returns with no data, and
the (incoming exec) migration fails.

Fix by retrying on such a case.

(cherry picked from commit 8a67ec4d84f7db9add9a0b017a968d340fbfb807)

Signed-off-by: Uri Lublin <uril@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
savevm.c

index 54137f87f4a5c74fad89ab9c3b22f73cb61b84a1..c7bc398d9767707fd4aa8113a8ed2de8db52f0bf 100644 (file)
--- a/savevm.c
+++ b/savevm.c
@@ -210,7 +210,14 @@ static int popen_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, int s
 static int popen_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
 {
     QEMUFilePopen *s = opaque;
-    return fread(buf, 1, size, s->popen_file);
+    FILE *fp = s->popen_file;
+    int bytes;
+
+    do {
+        clearerr(fp);
+        bytes = fread(buf, 1, size, fp);
+    } while ((bytes == 0) && ferror(fp) && (errno == EINTR));
+    return bytes;
 }
 
 static int popen_close(void *opaque)