From patchwork Wed Feb 10 23:09:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2/4] qemu-kvm: morph io_thread_wakeup into qemu.git's qemu_event_read Date: Wed, 10 Feb 2010 13:09:14 -0000 From: Paolo Bonzini X-Patchwork-Id: 45070 Message-Id: <1265843356-25765-3-git-send-email-pbonzini@redhat.com> To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org Again, no need to loop if less than a full buffer is read, the next read would return EAGAIN. Signed-off-by: Paolo Bonzini --- 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)