From: Dor Laor <dlaor@redhat.com>
To: kvm-devel <kvm@vger.kernel.org>
Subject: Fix migration issue when the destination is loaded
Date: Wed, 15 Jul 2009 18:03:15 +0300 [thread overview]
Message-ID: <4A5DEFB3.4060702@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: 0001-Fix-migration-issue-when-the-destination-is-loaded.patch --]
[-- Type: text/plain, Size: 1702 bytes --]
>From abbe3b57af6a28bb81e5fb8b09b10802a8ccc3fe Mon Sep 17 00:00:00 2001
From: Dor Laor <dor@redhat.com>
Date: Wed, 15 Jul 2009 17:53:16 +0300
Subject: [PATCH] Fix migration issue when the destination is loaded
If the migration socket is full, we get EAGAIN for the write.
The set_fd_handler2 defers the write for later on. The function
tries to wake up the iothread by qemu_kvm_notify_work.
Since this happens in a loop, multiple times, the pipe that emulates eventfd
becomes full and we get a deadlock.
It is solved by checking for write-readiness using select.
Note that I check for select only for full 8 byte write and not
for partial writes. This is because we'll break the reader otherwise.
Signed-off-by: Dor Laor <dor@redhat.com>
---
qemu-kvm.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/qemu-kvm.c b/qemu-kvm.c
index ed7e466..0ea67a7 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -2094,12 +2094,28 @@ void qemu_kvm_notify_work(void)
uint64_t value = 1;
char buffer[8];
size_t offset = 0;
+ fd_set wfds;
+ struct timeval tv;
+ int retval;
if (io_thread_fd == -1)
return;
memcpy(buffer, &value, sizeof(value));
+ FD_ZERO(&wfds);
+ FD_SET(io_thread_fd, &wfds);
+ tv.tv_sec = tv.tv_usec = 0;
+ retval = select(io_thread_fd + 1, NULL, &wfds, NULL, &tv);
+ if (retval == -1) {
+ fprintf(stderr, "failed to notify io thread due to select error\n");
+ return;
+ } else if (retval == 0)
+ /* We probably ponded this pipe too much and it is full now */
+ return;
+
+ assert(FD_ISSET(io_thread_fd, &wfds));
+
while (offset < 8) {
ssize_t len;
--
1.6.2.5
next reply other threads:[~2009-07-15 15:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-15 15:03 Dor Laor [this message]
2009-07-16 9:39 ` Fix migration issue when the destination is loaded Mark McLoughlin
2009-07-16 12:00 ` Dor Laor
2009-07-16 15:20 ` Mark McLoughlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A5DEFB3.4060702@redhat.com \
--to=dlaor@redhat.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.