qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] exec-migration: handle EINTR in popen_get_buffer()
@ 2009-06-08 16:27 Uri Lublin
  2009-06-08 16:55 ` Blue Swirl
  2009-06-08 17:54 ` Michael S. Tsirkin
  0 siblings, 2 replies; 8+ messages in thread
From: Uri Lublin @ 2009-06-08 16:27 UTC (permalink / raw)
  To: qemu-devel

Sometimes, upon interrupt, fread returns with no data, and
the (incoming exec) migration fails.

Fix by retrying on such a case.

Signed-off-by: Uri Lublin <uril@redhat.com>
---
 savevm.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/savevm.c b/savevm.c
index 248aea3..df2486d 100644
--- a/savevm.c
+++ b/savevm.c
@@ -215,7 +215,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)
-- 
1.6.2.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH] exec-migration: handle EINTR in popen_get_buffer()
@ 2009-06-02 16:49 Uri Lublin
  0 siblings, 0 replies; 8+ messages in thread
From: Uri Lublin @ 2009-06-02 16:49 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 119 bytes --]

Hello,


The attached patch fix occasional failures of incoming exec migrations.

Patch based on qemu-kvm.git.

Uri.



[-- Attachment #2: 0001-exec-migration-handle-EINTR-in-popen_get_buffer.patch --]
[-- Type: text/x-patch, Size: 1018 bytes --]

>From 0003cebfd2afdf03e2f2cff599691952950a05ce Mon Sep 17 00:00:00 2001
From: Uri Lublin <uril@redhat.com>
Date: Tue, 2 Jun 2009 17:09:57 +0300
Subject: [PATCH] exec-migration: handle EINTR in popen_get_buffer()

Upon interrupt, fread returns with no data, and
the (incoming exec) migration fails.

Fix by retrying on such a case.

Signed-off-by: Uri Lublin <uril@redhat.com>
---
 savevm.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/savevm.c b/savevm.c
index 68ffd03..f53de43 100644
--- a/savevm.c
+++ b/savevm.c
@@ -215,7 +215,12 @@ 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);
+    int bytes;
+
+    do {
+        bytes = fread(buf, 1, size, s->popen_file);
+    } while ((bytes == 0) && (errno == EINTR));
+    return bytes;
 }

 static int popen_close(void *opaque)
-- 
1.6.2.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-06-09 14:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-08 16:27 [Qemu-devel] [PATCH] exec-migration: handle EINTR in popen_get_buffer() Uri Lublin
2009-06-08 16:55 ` Blue Swirl
2009-06-09 10:49   ` Uri Lublin
2009-06-09 14:51     ` Blue Swirl
2009-06-08 17:54 ` Michael S. Tsirkin
2009-06-09 12:20   ` Michael S. Tsirkin
2009-06-09 12:32   ` Uri Lublin
  -- strict thread matches above, loose matches on Subject: below --
2009-06-02 16:49 Uri Lublin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).