diff options
author | Uri Lublin <uril@redhat.com> | 2009-06-08 19:27:21 +0300 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-06-16 17:11:13 -0500 |
commit | 936d7bf94412d08933389139631531ebc85b66ea (patch) | |
tree | e2c47a30519cd6ffba0ab9c5c17f0f015d1767ab | |
parent | d13317e197da0e85ba9b57332182c6363aee085d (diff) | |
download | qemu-936d7bf94412d08933389139631531ebc85b66ea.tar.gz |
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.
(cherry picked from commit 8a67ec4d84f7db9add9a0b017a968d340fbfb807)
Signed-off-by: Uri Lublin <uril@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | savevm.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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) |