From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M7tYb-0002en-N3 for qemu-devel@nongnu.org; Sat, 23 May 2009 11:54:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M7tYW-0002bU-JL for qemu-devel@nongnu.org; Sat, 23 May 2009 11:54:44 -0400 Received: from [199.232.76.173] (port=46780 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M7tYW-0002bR-F9 for qemu-devel@nongnu.org; Sat, 23 May 2009 11:54:40 -0400 Received: from mx2.redhat.com ([66.187.237.31]:33156) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M7tYV-0004AW-T2 for qemu-devel@nongnu.org; Sat, 23 May 2009 11:54:40 -0400 Message-ID: <4A181C57.50108@redhat.com> Date: Sat, 23 May 2009 18:55:03 +0300 From: Dor Laor MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] migrate.c: migrate_fd_put_buffer: Do not busyloop: stop writing if EWOULDBLOCK References: <1242731333-1526-1-git-send-email-uril@redhat.com> <4A151F9F.7050208@redhat.com> <4A16A696.8070902@us.ibm.com> In-Reply-To: <4A16A696.8070902@us.ibm.com> Content-Type: multipart/mixed; boundary="------------060001090501040609050302" Reply-To: dlaor@redhat.com List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Uri Lublin , qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------060001090501040609050302 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Anthony Liguori wrote: > > This is whitespace damaged, presumably from copy/paste, can you resend? > Here is a better one. --------------060001090501040609050302 Content-Type: text/plain; name="0001-The-migration-code-is-non-blocking-designed-for-liv.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0001-The-migration-code-is-non-blocking-designed-for-liv.pat"; filename*1="ch" >>From 2d875410cb168fa728dcde96885a3e4ddfd0bb58 Mon Sep 17 00:00:00 2001 From: Dor Laor Date: Thu, 21 May 2009 12:29:39 +0300 Subject: [PATCH] The migration code is non-blocking, designed for live migration. Practically migrate_fd_put_buffer busy-loops trying to write, as on many machines EWOULDBLOCK==EAGAIN (look in include/asm-generic/errno.h). Based on Uri Lublin's patch. Signed-off-by: Dor Laor --- qemu/buffered_file.c | 4 ++-- qemu/migration.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qemu/buffered_file.c b/qemu/buffered_file.c index be5baea..34cde6e 100644 --- a/qemu/buffered_file.c +++ b/qemu/buffered_file.c @@ -86,7 +86,7 @@ static void buffered_flush(QEMUFileBuffered *s) ret = s->put_buffer(s->opaque, s->buffer + offset, s->buffer_size - offset); - if (ret == -EAGAIN) { + if (ret == -EAGAIN || ret == -EWOULDBLOCK) { dprintf("backend not ready, freezing\n"); s->freeze_output = 1; break; @@ -132,7 +132,7 @@ static int buffered_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, in } ret = s->put_buffer(s->opaque, buf + offset, size - offset); - if (ret == -EAGAIN) { + if (ret == -EAGAIN || ret ==-EWOULDBLOCK) { dprintf("backend not ready, freezing\n"); s->freeze_output = 1; break; diff --git a/qemu/migration.c b/qemu/migration.c index 85757c5..8846eee 100644 --- a/qemu/migration.c +++ b/qemu/migration.c @@ -174,7 +174,7 @@ ssize_t migrate_fd_put_buffer(void *opaque, const void *data, size_t size) if (ret == -1) ret = -(s->get_error(s)); - if (ret == -EAGAIN) + if (ret == -EAGAIN || ret == -EWOULDBLOCK) qemu_set_fd_handler2(s->fd, NULL, NULL, migrate_fd_put_notify, s); return ret; -- 1.5.6.6 --------------060001090501040609050302--