All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu-char: use qemu_set_fd_handler/2 consistently
@ 2011-09-16 21:19 Marcelo Tosatti
  2011-09-23 18:50 ` Anthony Liguori
  0 siblings, 1 reply; 2+ messages in thread
From: Marcelo Tosatti @ 2011-09-16 21:19 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel


Now that qemu_set_fd_handler and qemu_set_fd_handler2 have different
implementations, one using qemu iohandlers and the other glib, it is not
safe to mix the two when inserting/deleting handlers.

Fixes kvm-autotest.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

diff --git a/qemu-char.c b/qemu-char.c
index c9e5c41..09d2309 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1881,7 +1881,7 @@ static void udp_chr_close(CharDriverState *chr)
 {
     NetCharDriver *s = chr->opaque;
     if (s->fd >= 0) {
-        qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
+        qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
         closesocket(s->fd);
     }
     g_free(s);
@@ -2093,9 +2093,9 @@ static void tcp_chr_read(void *opaque)
         /* connection closed */
         s->connected = 0;
         if (s->listen_fd >= 0) {
-            qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, chr);
+            qemu_set_fd_handler2(s->listen_fd, NULL, tcp_chr_accept, NULL, chr);
         }
-        qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
+        qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
         closesocket(s->fd);
         s->fd = -1;
         qemu_chr_event(chr, CHR_EVENT_CLOSED);
@@ -2156,7 +2156,7 @@ static int tcp_chr_add_client(CharDriverState *chr, int fd)
     if (s->do_nodelay)
         socket_set_nodelay(fd);
     s->fd = fd;
-    qemu_set_fd_handler(s->listen_fd, NULL, NULL, NULL);
+    qemu_set_fd_handler2(s->listen_fd, NULL, NULL, NULL, NULL);
     tcp_chr_connect(chr);
 
     return 0;
@@ -2202,11 +2202,11 @@ static void tcp_chr_close(CharDriverState *chr)
 {
     TCPCharDriver *s = chr->opaque;
     if (s->fd >= 0) {
-        qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
+        qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
         closesocket(s->fd);
     }
     if (s->listen_fd >= 0) {
-        qemu_set_fd_handler(s->listen_fd, NULL, NULL, NULL);
+        qemu_set_fd_handler2(s->listen_fd, NULL, NULL, NULL, NULL);
         closesocket(s->listen_fd);
     }
     g_free(s);
@@ -2272,7 +2272,7 @@ static int qemu_chr_open_socket(QemuOpts *opts, CharDriverState **_chr)
 
     if (is_listen) {
         s->listen_fd = fd;
-        qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, chr);
+        qemu_set_fd_handler2(s->listen_fd, NULL, tcp_chr_accept, NULL, chr);
         if (is_telnet)
             s->do_telnetopt = 1;
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-char: use qemu_set_fd_handler/2 consistently
  2011-09-16 21:19 [Qemu-devel] [PATCH] qemu-char: use qemu_set_fd_handler/2 consistently Marcelo Tosatti
@ 2011-09-23 18:50 ` Anthony Liguori
  0 siblings, 0 replies; 2+ messages in thread
From: Anthony Liguori @ 2011-09-23 18:50 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: qemu-devel

On 09/16/2011 04:19 PM, Marcelo Tosatti wrote:
>
> Now that qemu_set_fd_handler and qemu_set_fd_handler2 have different
> implementations, one using qemu iohandlers and the other glib, it is not
> safe to mix the two when inserting/deleting handlers.
>
> Fixes kvm-autotest.
>
> Signed-off-by: Marcelo Tosatti<mtosatti@redhat.com>

Applied.  Thanks.

Regards,

Anthony Liguori
>
> diff --git a/qemu-char.c b/qemu-char.c
> index c9e5c41..09d2309 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -1881,7 +1881,7 @@ static void udp_chr_close(CharDriverState *chr)
>   {
>       NetCharDriver *s = chr->opaque;
>       if (s->fd>= 0) {
> -        qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
> +        qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
>           closesocket(s->fd);
>       }
>       g_free(s);
> @@ -2093,9 +2093,9 @@ static void tcp_chr_read(void *opaque)
>           /* connection closed */
>           s->connected = 0;
>           if (s->listen_fd>= 0) {
> -            qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, chr);
> +            qemu_set_fd_handler2(s->listen_fd, NULL, tcp_chr_accept, NULL, chr);
>           }
> -        qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
> +        qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
>           closesocket(s->fd);
>           s->fd = -1;
>           qemu_chr_event(chr, CHR_EVENT_CLOSED);
> @@ -2156,7 +2156,7 @@ static int tcp_chr_add_client(CharDriverState *chr, int fd)
>       if (s->do_nodelay)
>           socket_set_nodelay(fd);
>       s->fd = fd;
> -    qemu_set_fd_handler(s->listen_fd, NULL, NULL, NULL);
> +    qemu_set_fd_handler2(s->listen_fd, NULL, NULL, NULL, NULL);
>       tcp_chr_connect(chr);
>
>       return 0;
> @@ -2202,11 +2202,11 @@ static void tcp_chr_close(CharDriverState *chr)
>   {
>       TCPCharDriver *s = chr->opaque;
>       if (s->fd>= 0) {
> -        qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
> +        qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
>           closesocket(s->fd);
>       }
>       if (s->listen_fd>= 0) {
> -        qemu_set_fd_handler(s->listen_fd, NULL, NULL, NULL);
> +        qemu_set_fd_handler2(s->listen_fd, NULL, NULL, NULL, NULL);
>           closesocket(s->listen_fd);
>       }
>       g_free(s);
> @@ -2272,7 +2272,7 @@ static int qemu_chr_open_socket(QemuOpts *opts, CharDriverState **_chr)
>
>       if (is_listen) {
>           s->listen_fd = fd;
> -        qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, chr);
> +        qemu_set_fd_handler2(s->listen_fd, NULL, tcp_chr_accept, NULL, chr);
>           if (is_telnet)
>               s->do_telnetopt = 1;
>
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-23 18:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-16 21:19 [Qemu-devel] [PATCH] qemu-char: use qemu_set_fd_handler/2 consistently Marcelo Tosatti
2011-09-23 18:50 ` 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.