* [Qemu-devel] [PATCH 0/3] Event signaling tweaks
@ 2010-02-02 19:33 Paolo Bonzini
2010-02-02 19:33 ` [Qemu-devel] [PATCH 1/3] do not loop on an incomplete io_thread_fd read Paolo Bonzini
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Paolo Bonzini @ 2010-02-02 19:33 UTC (permalink / raw)
To: qemu-devel
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(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 1/3] do not loop on an incomplete io_thread_fd read
2010-02-02 19:33 [Qemu-devel] [PATCH 0/3] Event signaling tweaks Paolo Bonzini
@ 2010-02-02 19:33 ` Paolo Bonzini
2010-02-10 18:32 ` Anthony Liguori
2010-02-02 19:33 ` [Qemu-devel] [PATCH 2/3] loop write in qemu_event_increment upon EINTR Paolo Bonzini
2010-02-02 19:33 ` [Qemu-devel] [PATCH 3/3] fix placement of config-host.h inclusion Paolo Bonzini
2 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2010-02-02 19:33 UTC (permalink / raw)
To: qemu-devel
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>
---
vl.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/vl.c b/vl.c
index 6f1e1ab..46c1118 100644
--- a/vl.c
+++ b/vl.c
@@ -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)
--
1.6.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 2/3] loop write in qemu_event_increment upon EINTR
2010-02-02 19:33 [Qemu-devel] [PATCH 0/3] Event signaling tweaks Paolo Bonzini
2010-02-02 19:33 ` [Qemu-devel] [PATCH 1/3] do not loop on an incomplete io_thread_fd read Paolo Bonzini
@ 2010-02-02 19:33 ` Paolo Bonzini
2010-02-02 19:33 ` [Qemu-devel] [PATCH 3/3] fix placement of config-host.h inclusion Paolo Bonzini
2 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2010-02-02 19:33 UTC (permalink / raw)
To: qemu-devel
Same as what qemu-kvm does.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
vl.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/vl.c b/vl.c
index 46c1118..f150eca 100644
--- a/vl.c
+++ b/vl.c
@@ -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);
--
1.6.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 3/3] fix placement of config-host.h inclusion
2010-02-02 19:33 [Qemu-devel] [PATCH 0/3] Event signaling tweaks Paolo Bonzini
2010-02-02 19:33 ` [Qemu-devel] [PATCH 1/3] do not loop on an incomplete io_thread_fd read Paolo Bonzini
2010-02-02 19:33 ` [Qemu-devel] [PATCH 2/3] loop write in qemu_event_increment upon EINTR Paolo Bonzini
@ 2010-02-02 19:33 ` Paolo Bonzini
2 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2010-02-02 19:33 UTC (permalink / raw)
To: qemu-devel
The #ifdef CONFIG_SOLARIS below was useless without this patch.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
osdep.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/osdep.c b/osdep.c
index cf3a2c6..9059f01 100644
--- a/osdep.c
+++ b/osdep.c
@@ -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)
--
1.6.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] do not loop on an incomplete io_thread_fd read
2010-02-02 19:33 ` [Qemu-devel] [PATCH 1/3] do not loop on an incomplete io_thread_fd read Paolo Bonzini
@ 2010-02-10 18:32 ` Anthony Liguori
0 siblings, 0 replies; 5+ messages in thread
From: Anthony Liguori @ 2010-02-10 18:32 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On 02/02/2010 01:33 PM, Paolo Bonzini wrote:
> 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>
>
Applied all. Thanks.
Regards,
Anthony Liguori
> ---
> vl.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index 6f1e1ab..46c1118 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -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)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-02-10 18:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-02 19:33 [Qemu-devel] [PATCH 0/3] Event signaling tweaks Paolo Bonzini
2010-02-02 19:33 ` [Qemu-devel] [PATCH 1/3] do not loop on an incomplete io_thread_fd read Paolo Bonzini
2010-02-10 18:32 ` Anthony Liguori
2010-02-02 19:33 ` [Qemu-devel] [PATCH 2/3] loop write in qemu_event_increment upon EINTR Paolo Bonzini
2010-02-02 19:33 ` [Qemu-devel] [PATCH 3/3] fix placement of config-host.h inclusion Paolo Bonzini
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).