From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MDhh5-0004wj-77 for qemu-devel@nongnu.org; Mon, 08 Jun 2009 12:27:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MDhh0-0004r9-Hq for qemu-devel@nongnu.org; Mon, 08 Jun 2009 12:27:30 -0400 Received: from [199.232.76.173] (port=44820 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MDhh0-0004r1-F2 for qemu-devel@nongnu.org; Mon, 08 Jun 2009 12:27:26 -0400 Received: from mx2.redhat.com ([66.187.237.31]:58929) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MDhgz-0005XC-2T for qemu-devel@nongnu.org; Mon, 08 Jun 2009 12:27:25 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n58GROb5023124 for ; Mon, 8 Jun 2009 12:27:24 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n58GRN9k017315 for ; Mon, 8 Jun 2009 12:27:23 -0400 Received: from localhost.localdomain (dhcp-1-187.tlv.redhat.com [10.35.1.187]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n58GRLEs032384 for ; Mon, 8 Jun 2009 12:27:22 -0400 From: Uri Lublin Date: Mon, 8 Jun 2009 19:27:21 +0300 Message-Id: <1244478441-26288-1-git-send-email-uril@redhat.com> Subject: [Qemu-devel] [PATCH] exec-migration: handle EINTR in popen_get_buffer() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 --- 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