Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main-src > by-pkgid > aadbe78a25743146bb784eee19f007c5 > files > 268

kvm-83-164.el5_5.9.src.rpm

From 2722bb7d2217995ffc1ee0666a9a78ac4c5e1c3e Mon Sep 17 00:00:00 2001
From: Uri Lublin <uril@redhat.com>
Date: Mon, 8 Jun 2009 18:40:04 +0300
Subject: [PATCH 5/5] exec-migration: handle EINTR in popen_get_buffer() (v3)

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

Fix by retrying on such a case.

Changes from v2:
    using clearerr and ferror
    using a local variable fp

bz 501693

Signed-off-by: Uri Lublin <uril@redhat.com>
Message-Id: <1244475604-25852-1-git-send-email-uril@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
RH-Upstream-status: pending
Obsoletes: <1243956781-29993-5-git-send-email-uril@redhat.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Acked-by: Gleb Natapov <gleb@redhat.com>
Bugzilla: 504237
---
 qemu/savevm.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/qemu/savevm.c b/qemu/savevm.c
index bc2652a..f3b9707 100644
--- a/qemu/savevm.c
+++ b/qemu/savevm.c
@@ -211,7 +211,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.3.rc4.29.g8146