Commit 8a67ec4d84f7db9add9a0b017a968d340fbfb807

Authored by Uri Lublin
Committed by Anthony Liguori
1 parent d084eab6

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>
Showing 1 changed file with 8 additions and 1 deletions
savevm.c
... ... @@ -215,7 +215,14 @@ static int popen_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, int s
215 215 static int popen_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
216 216 {
217 217 QEMUFilePopen *s = opaque;
218   - return fread(buf, 1, size, s->popen_file);
  218 + FILE *fp = s->popen_file;
  219 + int bytes;
  220 +
  221 + do {
  222 + clearerr(fp);
  223 + bytes = fread(buf, 1, size, fp);
  224 + } while ((bytes == 0) && ferror(fp) && (errno == EINTR));
  225 + return bytes;
219 226 }
220 227  
221 228 static int popen_close(void *opaque)
... ...