aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUri Lublin <uril@redhat.com>2009-06-08 19:27:21 +0300
committerAnthony Liguori <aliguori@us.ibm.com>2009-06-13 19:19:25 -0500
commit8a67ec4d84f7db9add9a0b017a968d340fbfb807 (patch)
tree84e3a497357c1fb6c4a4b0f2af9a724e3a432673
parentd084eab6f820bf914d798a99eaa4f20113f6e151 (diff)
exec-migration: handle EINTR in popen_get_buffer()
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> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--savevm.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/savevm.c b/savevm.c
index 61edd7e458..17da35a9fb 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)