From f3dfda6114fd12ca7caac456b1997962b5c48274 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 11 Feb 2010 00:23:46 +0100 Subject: use eventfd for iothread Signed-off-by: Paolo Bonzini Signed-off-by: Avi Kivity --- vl.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index 98918ac49d..1957018cf6 100644 --- a/vl.c +++ b/vl.c @@ -3211,14 +3211,15 @@ static int io_thread_fd = -1; static void qemu_event_increment(void) { - static const char byte = 0; + /* Write 8 bytes to be compatible with eventfd. */ + static uint64_t val = 1; ssize_t ret; if (io_thread_fd == -1) return; do { - ret = write(io_thread_fd, &byte, sizeof(byte)); + ret = write(io_thread_fd, &val, sizeof(val)); } while (ret < 0 && errno == EINTR); /* EAGAIN is fine, a read must be pending. */ @@ -3235,7 +3236,7 @@ static void qemu_event_read(void *opaque) ssize_t len; char buffer[512]; - /* Drain the notify pipe */ + /* Drain the notify pipe. For eventfd, only 8 bytes will be read. */ do { len = read(fd, buffer, sizeof(buffer)); } while ((len == -1 && errno == EINTR) || len == sizeof(buffer)); @@ -3246,7 +3247,7 @@ static int qemu_event_init(void) int err; int fds[2]; - err = qemu_pipe(fds); + err = qemu_eventfd(fds); if (err == -1) return -errno; -- cgit v1.2.3