Event signaling tweaks
cover Event signaling tweaks
This series of three patches makes two small changes to qemu_event_read and qemu_event_increment. These are preparatory to merging eventfd usage in the iothread from qemu-kvm (which would have conflicts, so it has to be done with some care).
Paolo Bonzini (3):
do not loop on an incomplete io_thread_fd read
loop qemu_event_increment if we have an EINTR
fix placement of config-host.h inclusion
osdep.c | 7 ++++--- vl.c | 12 ++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-)
PATCH 1/3 do not loop on an incomplete io_thread_fd read
No need to loop if less than a full buffer is read, the next read would return EAGAIN.
--- vl.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
vl.c +2 -2
@@ -3210,12 +3210,12 @@ static void qemu_event_read(void *opaque) {int fd = (unsigned long )opaque;ssize_t len; +char buffer[512 ];/* Drain the notify pipe */ do { -char buffer[512 ]; len =read (fd, buffer,sizeof (buffer)); - }while ((len ==-1 && errno ==EINTR ) || len >0 ); + }while ((len ==-1 && errno ==EINTR ) || len ==sizeof (buffer)); }static int qemu_event_init (void )
Signature · 1 line
1.6.6
Anthony Liguori
AppliedRe: [Qemu-devel] [PATCH 1/3] do not loop on an incomplete io_thread_fd read
Quoted 5 lines · Paolo Bonzini
No need to loop if less than a full buffer is read, the next read would return EAGAIN.
Signed-off-by Paolo Bonzini<[email protected]>
Applied all. Thanks.
Regards,
Anthony Liguori
Quoted 24 lines
--- vl.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)vl.c +2
-2@@ -3210,12 +3210,12 @@ static void qemu_event_read(void *opaque) {int fd = (unsigned long )opaque;ssize_t len; +char buffer[512 ];/* Drain the notify pipe */ do { -char buffer[512 ]; len =read (fd, buffer,sizeof (buffer)); - }while ((len ==-1 && errno ==EINTR ) || len>0 ); + }while ((len ==-1 && errno ==EINTR ) || len ==sizeof (buffer)); }static int qemu_event_init (void )
PATCH 2/3 loop write in qemu_event_increment upon EINTR
In reply to Paolo BonziniSame as what qemu-kvm does.
--- vl.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
vl.c +6 -2
@@ -3198,8 +3198,12 @@ static void qemu_event_increment(void)if (io_thread_fd ==-1 )return ; - ret =write (io_thread_fd, &byte,sizeof (byte)); -if (ret <0 && (errno !=EINTR && errno !=EAGAIN )) { +do { + ret =write (io_thread_fd, &byte,sizeof (byte)); + }while (ret <0 && errno ==EINTR ); + +/* EAGAIN is fine, a read must be pending. */ +if (ret <0 && errno !=EAGAIN ) {fprintf (stderr,"qemu_event_increment: write() filed: %s\n" ,strerror (errno));exit (1 );
Signature · 1 line
1.6.6
PATCH 3/3 fix placement of config-host.h inclusion
In reply to Paolo BonziniThe #ifdef CONFIG_SOLARIS below was useless without this patch.
--- osdep.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
osdep.c +4 -3
@@ -28,14 +28,15 @@#include <errno.h> #include <unistd.h> #include <fcntl.h> + +/* Needed early for CONFIG_BSD etc. */ +#include "config-host.h" +#ifdef CONFIG_SOLARIS #include <sys/types.h> #include <sys/statvfs.h> #endif -/* Needed early for CONFIG_BSD etc. */ -#include "config-host.h" -#ifdef _WIN32#include <windows.h> #elif defined(CONFIG_BSD )
Signature · 1 line
1.6.6