From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH 2/4] qemu-kvm: morph io_thread_wakeup into qemu.git's qemu_event_read
Date: Thu, 11 Feb 2010 00:09:14 +0100 [thread overview]
Message-ID: <1265843356-25765-3-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1265843356-25765-1-git-send-email-pbonzini@redhat.com>
Again, no need to loop if less than a full buffer is read, the next
read would return EAGAIN.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
qemu-kvm.c | 16 +++++-----------
1 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 669a784..50e1303 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -2049,19 +2049,13 @@ static void sigfd_handler(void *opaque)
static void io_thread_wakeup(void *opaque)
{
int fd = (unsigned long) opaque;
- char buffer[4096];
-
- /* Drain the pipe/(eventfd) */
- while (1) {
- ssize_t len;
+ ssize_t len;
+ char buffer[512];
+ /* Drain the notify pipe. For eventfd, only 8 bytes will be read. */
+ do {
len = read(fd, buffer, sizeof(buffer));
- if (len == -1 && errno == EINTR)
- continue;
-
- if (len <= 0)
- break;
- }
+ } while ((len == -1 && errno == EINTR) || len == sizeof(buffer));
}
int kvm_main_loop(void)
--
1.6.6
next prev parent reply other threads:[~2010-02-10 23:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-10 23:09 [Qemu-devel] [PATCH 0/4] qemu-kvm: prepare for adding eventfd usage to upstream Paolo Bonzini
2010-02-10 23:09 ` [Qemu-devel] [PATCH 1/4] qemu-kvm: morph qemu_kvm_notify_work into qemu.git's qemu_event_increment Paolo Bonzini
2010-02-10 23:09 ` Paolo Bonzini [this message]
2010-02-10 23:09 ` [Qemu-devel] [PATCH 3/4] qemu-kvm: fix placement of config-host.h inclusion Paolo Bonzini
2010-02-10 23:09 ` [Qemu-devel] [PATCH 4/4] qemu-kvm: move qemu_eventfd to osdep.c Paolo Bonzini
2010-02-13 13:26 ` [Qemu-devel] Re: [PATCH 0/4] qemu-kvm: prepare for adding eventfd usage to upstream Marcelo Tosatti
2010-02-14 12:32 ` Avi Kivity
2010-02-17 12:53 ` Avi Kivity
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=1265843356-25765-3-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).