* [Qemu-devel] [PATCH for-1.5 0/2] main-loop: fix slirp on win32
@ 2013-05-16 15:35 Stefan Hajnoczi
2013-05-16 15:36 ` [Qemu-devel] [PATCH for-1.5 1/2] main-loop: narrow win32 pollfds_fill() event bitmasks Stefan Hajnoczi
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Stefan Hajnoczi @ 2013-05-16 15:35 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Anthony Liguori, therock247uk, Stefan Hajnoczi, geleman
User networking is broken on win32. These patches resolve the issues.
TeLeMan and therock247uk: Please apply these patches and confirm that they fix
the bug.
Paolo: Please let me know if you want to take Author:.
Stefan Hajnoczi (2):
main-loop: narrow win32 pollfds_fill() event bitmasks
main-loop: partial revert of 5e3bc73
main-loop.c | 40 ++++++++++++++++++----------------------
1 file changed, 18 insertions(+), 22 deletions(-)
--
1.8.1.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH for-1.5 1/2] main-loop: narrow win32 pollfds_fill() event bitmasks
2013-05-16 15:35 [Qemu-devel] [PATCH for-1.5 0/2] main-loop: fix slirp on win32 Stefan Hajnoczi
@ 2013-05-16 15:36 ` Stefan Hajnoczi
2013-05-16 15:36 ` [Qemu-devel] [PATCH for-1.5 2/2] main-loop: partial revert of 5e3bc73 Stefan Hajnoczi
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Stefan Hajnoczi @ 2013-05-16 15:36 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Anthony Liguori, therock247uk, Stefan Hajnoczi, geleman
pollfds_fill() and pollfds_poll() translate GPollFD to rfds/wfds/xfds
for sockets on win32. select(2) is the underlying system call which is
used to monitor sockets for activity.
Currently file descriptors that monitor G_IO_ERR will be included in
both rfds and wfds. As a result, select(2) will report writability on
file descriptors where we only really wanted to monitor readability
(with errors).
slirp_pollfds_poll() hit this issue: UDP sockets are blocking sockets so
we hang in sorecvfrom() when G_IO_ERR is set due to the socket being
writable (we only wanted to check for readability).
This patch fixes the slirp_pollfds_poll() hang.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
main-loop.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/main-loop.c b/main-loop.c
index f46aece..2b8eed7 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -333,11 +333,11 @@ static int pollfds_fill(GArray *pollfds, fd_set *rfds, fd_set *wfds,
GPollFD *pfd = &g_array_index(pollfds, GPollFD, i);
int fd = pfd->fd;
int events = pfd->events;
- if (events & (G_IO_IN | G_IO_HUP | G_IO_ERR)) {
+ if (events & G_IO_IN) {
FD_SET(fd, rfds);
nfds = MAX(nfds, fd);
}
- if (events & (G_IO_OUT | G_IO_ERR)) {
+ if (events & G_IO_OUT) {
FD_SET(fd, wfds);
nfds = MAX(nfds, fd);
}
@@ -360,10 +360,10 @@ static void pollfds_poll(GArray *pollfds, int nfds, fd_set *rfds,
int revents = 0;
if (FD_ISSET(fd, rfds)) {
- revents |= G_IO_IN | G_IO_HUP | G_IO_ERR;
+ revents |= G_IO_IN;
}
if (FD_ISSET(fd, wfds)) {
- revents |= G_IO_OUT | G_IO_ERR;
+ revents |= G_IO_OUT;
}
if (FD_ISSET(fd, xfds)) {
revents |= G_IO_PRI;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH for-1.5 2/2] main-loop: partial revert of 5e3bc73
2013-05-16 15:35 [Qemu-devel] [PATCH for-1.5 0/2] main-loop: fix slirp on win32 Stefan Hajnoczi
2013-05-16 15:36 ` [Qemu-devel] [PATCH for-1.5 1/2] main-loop: narrow win32 pollfds_fill() event bitmasks Stefan Hajnoczi
@ 2013-05-16 15:36 ` Stefan Hajnoczi
2013-05-16 16:54 ` Paolo Bonzini
2013-05-16 16:54 ` [Qemu-devel] [PATCH for-1.5 0/2] main-loop: fix slirp on win32 Paolo Bonzini
` (2 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Stefan Hajnoczi @ 2013-05-16 15:36 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Anthony Liguori, therock247uk, Stefan Hajnoczi, geleman
This patch reverts part of 5e3bc735d93dd23f074b5116fd11e1ad8cd4962f.
Paolo Bonzini wrote this patch and commented:
"WSAEventSelect is edge-triggered and the event will not be signaled if
the socket handler does not consume all the data in the socket buffer."
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
main-loop.c | 32 ++++++++++++++------------------
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/main-loop.c b/main-loop.c
index 2b8eed7..cf36645 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -394,6 +394,20 @@ static int os_host_main_loop_wait(uint32_t timeout)
return ret;
}
+ FD_ZERO(&rfds);
+ FD_ZERO(&wfds);
+ FD_ZERO(&xfds);
+ nfds = pollfds_fill(gpollfds, &rfds, &wfds, &xfds);
+ if (nfds >= 0) {
+ select_ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv0);
+ if (select_ret != 0) {
+ timeout = 0;
+ }
+ if (select_ret > 0) {
+ pollfds_poll(gpollfds, nfds, &rfds, &wfds, &xfds);
+ }
+ }
+
g_main_context_prepare(context, &max_priority);
n_poll_fds = g_main_context_query(context, max_priority, &poll_timeout,
poll_fds, ARRAY_SIZE(poll_fds));
@@ -426,24 +440,6 @@ static int os_host_main_loop_wait(uint32_t timeout)
g_main_context_dispatch(context);
}
- /* Call select after g_poll to avoid a useless iteration and therefore
- * improve socket latency.
- */
-
- FD_ZERO(&rfds);
- FD_ZERO(&wfds);
- FD_ZERO(&xfds);
- nfds = pollfds_fill(gpollfds, &rfds, &wfds, &xfds);
- if (nfds >= 0) {
- select_ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv0);
- if (select_ret != 0) {
- timeout = 0;
- }
- if (select_ret > 0) {
- pollfds_poll(gpollfds, nfds, &rfds, &wfds, &xfds);
- }
- }
-
return select_ret || g_poll_ret;
}
#endif
--
1.8.1.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.5 0/2] main-loop: fix slirp on win32
2013-05-16 15:35 [Qemu-devel] [PATCH for-1.5 0/2] main-loop: fix slirp on win32 Stefan Hajnoczi
2013-05-16 15:36 ` [Qemu-devel] [PATCH for-1.5 1/2] main-loop: narrow win32 pollfds_fill() event bitmasks Stefan Hajnoczi
2013-05-16 15:36 ` [Qemu-devel] [PATCH for-1.5 2/2] main-loop: partial revert of 5e3bc73 Stefan Hajnoczi
@ 2013-05-16 16:54 ` Paolo Bonzini
2013-05-17 1:25 ` TeLeMan
2013-05-22 22:58 ` Anthony Liguori
4 siblings, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2013-05-16 16:54 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: geleman, Anthony Liguori, therock247uk, qemu-devel
Il 16/05/2013 17:35, Stefan Hajnoczi ha scritto:
> User networking is broken on win32. These patches resolve the issues.
>
> TeLeMan and therock247uk: Please apply these patches and confirm that they fix
> the bug.
>
> Paolo: Please let me know if you want to take Author:.
No worries, thanks.
Paolo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.5 2/2] main-loop: partial revert of 5e3bc73
2013-05-16 15:36 ` [Qemu-devel] [PATCH for-1.5 2/2] main-loop: partial revert of 5e3bc73 Stefan Hajnoczi
@ 2013-05-16 16:54 ` Paolo Bonzini
0 siblings, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2013-05-16 16:54 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: geleman, Anthony Liguori, therock247uk, qemu-devel
Il 16/05/2013 17:36, Stefan Hajnoczi ha scritto:
> This patch reverts part of 5e3bc735d93dd23f074b5116fd11e1ad8cd4962f.
>
> Paolo Bonzini wrote this patch and commented:
>
> "WSAEventSelect is edge-triggered and the event will not be signaled if
> the socket handler does not consume all the data in the socket buffer."
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> main-loop.c | 32 ++++++++++++++------------------
> 1 file changed, 14 insertions(+), 18 deletions(-)
>
> diff --git a/main-loop.c b/main-loop.c
> index 2b8eed7..cf36645 100644
> --- a/main-loop.c
> +++ b/main-loop.c
> @@ -394,6 +394,20 @@ static int os_host_main_loop_wait(uint32_t timeout)
> return ret;
> }
>
> + FD_ZERO(&rfds);
> + FD_ZERO(&wfds);
> + FD_ZERO(&xfds);
> + nfds = pollfds_fill(gpollfds, &rfds, &wfds, &xfds);
> + if (nfds >= 0) {
> + select_ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv0);
> + if (select_ret != 0) {
> + timeout = 0;
> + }
> + if (select_ret > 0) {
> + pollfds_poll(gpollfds, nfds, &rfds, &wfds, &xfds);
> + }
> + }
> +
> g_main_context_prepare(context, &max_priority);
> n_poll_fds = g_main_context_query(context, max_priority, &poll_timeout,
> poll_fds, ARRAY_SIZE(poll_fds));
> @@ -426,24 +440,6 @@ static int os_host_main_loop_wait(uint32_t timeout)
> g_main_context_dispatch(context);
> }
>
> - /* Call select after g_poll to avoid a useless iteration and therefore
> - * improve socket latency.
> - */
> -
> - FD_ZERO(&rfds);
> - FD_ZERO(&wfds);
> - FD_ZERO(&xfds);
> - nfds = pollfds_fill(gpollfds, &rfds, &wfds, &xfds);
> - if (nfds >= 0) {
> - select_ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv0);
> - if (select_ret != 0) {
> - timeout = 0;
> - }
> - if (select_ret > 0) {
> - pollfds_poll(gpollfds, nfds, &rfds, &wfds, &xfds);
> - }
> - }
> -
> return select_ret || g_poll_ret;
> }
> #endif
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.5 0/2] main-loop: fix slirp on win32
2013-05-16 15:35 [Qemu-devel] [PATCH for-1.5 0/2] main-loop: fix slirp on win32 Stefan Hajnoczi
` (2 preceding siblings ...)
2013-05-16 16:54 ` [Qemu-devel] [PATCH for-1.5 0/2] main-loop: fix slirp on win32 Paolo Bonzini
@ 2013-05-17 1:25 ` TeLeMan
2013-05-17 8:01 ` Paolo Bonzini
2013-05-22 22:58 ` Anthony Liguori
4 siblings, 1 reply; 8+ messages in thread
From: TeLeMan @ 2013-05-17 1:25 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Paolo Bonzini, Anthony Liguori, therock247uk, qemu-devel
On Thu, May 16, 2013 at 11:35 PM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> User networking is broken on win32. These patches resolve the issues.
>
> TeLeMan and therock247uk: Please apply these patches and confirm that they fix
> the bug.
>
> Paolo: Please let me know if you want to take Author:.
>
> Stefan Hajnoczi (2):
> main-loop: narrow win32 pollfds_fill() event bitmasks
> main-loop: partial revert of 5e3bc73
>
> main-loop.c | 40 ++++++++++++++++++----------------------
> 1 file changed, 18 insertions(+), 22 deletions(-)
>
> --
> 1.8.1.4
>
Yeah, It works.
Tested-by: TeLeMan <geleman@gmail.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.5 0/2] main-loop: fix slirp on win32
2013-05-17 1:25 ` TeLeMan
@ 2013-05-17 8:01 ` Paolo Bonzini
0 siblings, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2013-05-17 8:01 UTC (permalink / raw)
To: TeLeMan; +Cc: Anthony Liguori, therock247uk, qemu-devel, Stefan Hajnoczi
Il 17/05/2013 03:25, TeLeMan ha scritto:
> On Thu, May 16, 2013 at 11:35 PM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
>> User networking is broken on win32. These patches resolve the issues.
>>
>> TeLeMan and therock247uk: Please apply these patches and confirm that they fix
>> the bug.
>>
>> Paolo: Please let me know if you want to take Author:.
>>
>> Stefan Hajnoczi (2):
>> main-loop: narrow win32 pollfds_fill() event bitmasks
>> main-loop: partial revert of 5e3bc73
>>
>> main-loop.c | 40 ++++++++++++++++++----------------------
>> 1 file changed, 18 insertions(+), 22 deletions(-)
>>
>> --
>> 1.8.1.4
>
> Yeah, It works.
>
> Tested-by: TeLeMan <geleman@gmail.com>
Thanks for your help!
Paolo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.5 0/2] main-loop: fix slirp on win32
2013-05-16 15:35 [Qemu-devel] [PATCH for-1.5 0/2] main-loop: fix slirp on win32 Stefan Hajnoczi
` (3 preceding siblings ...)
2013-05-17 1:25 ` TeLeMan
@ 2013-05-22 22:58 ` Anthony Liguori
4 siblings, 0 replies; 8+ messages in thread
From: Anthony Liguori @ 2013-05-22 22:58 UTC (permalink / raw)
To: Stefan Hajnoczi, qemu-devel; +Cc: Anthony Liguori, Paolo Bonzini, therock247uk
Applied. Thanks.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-05-22 22:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-16 15:35 [Qemu-devel] [PATCH for-1.5 0/2] main-loop: fix slirp on win32 Stefan Hajnoczi
2013-05-16 15:36 ` [Qemu-devel] [PATCH for-1.5 1/2] main-loop: narrow win32 pollfds_fill() event bitmasks Stefan Hajnoczi
2013-05-16 15:36 ` [Qemu-devel] [PATCH for-1.5 2/2] main-loop: partial revert of 5e3bc73 Stefan Hajnoczi
2013-05-16 16:54 ` Paolo Bonzini
2013-05-16 16:54 ` [Qemu-devel] [PATCH for-1.5 0/2] main-loop: fix slirp on win32 Paolo Bonzini
2013-05-17 1:25 ` TeLeMan
2013-05-17 8:01 ` Paolo Bonzini
2013-05-22 22:58 ` Anthony Liguori
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.