diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2010-02-11 00:09:14 +0100 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-02-17 14:52:05 +0200 |
commit | 71c02bf14dbe2619796c4c33cc9582f10a44ee60 (patch) | |
tree | 2e0e3f2628b143bcd7a362a1e17d8c016000f48a /qemu-kvm.c | |
parent | 6ff317702d178d1a25db4d72b1a9787250f93702 (diff) |
Morph io_thread_wakeup into qemu.git's qemu_event_read
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>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'qemu-kvm.c')
-rw-r--r-- | qemu-kvm.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/qemu-kvm.c b/qemu-kvm.c index 09eebefcf..b534d4e9c 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -2058,19 +2058,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) |