From patchwork Tue Mar 9 22:25:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 47201 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0CE2CB7D27 for ; Wed, 10 Mar 2010 10:37:00 +1100 (EST) Received: from localhost ([127.0.0.1]:43862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Np8xS-0000nB-Pg for incoming@patchwork.ozlabs.org; Tue, 09 Mar 2010 18:35:26 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Np8lY-0007RR-1g for qemu-devel@nongnu.org; Tue, 09 Mar 2010 18:23:08 -0500 Received: from [199.232.76.173] (port=36074 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Np8lX-0007Qf-6o for qemu-devel@nongnu.org; Tue, 09 Mar 2010 18:23:07 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Np8lV-0007Gx-FL for qemu-devel@nongnu.org; Tue, 09 Mar 2010 18:23:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19467) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Np8lV-0007Gr-0W for qemu-devel@nongnu.org; Tue, 09 Mar 2010 18:23:05 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o29MQBVc028744 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 9 Mar 2010 17:26:11 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o29MQ3Qb017445; Tue, 9 Mar 2010 17:26:10 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 9 Mar 2010 23:25:58 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 4/9] Introduce qemu_set_fd_write_handler() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Patch consist: s/qemu_set_fd_handler(fd, NULL, write, o)/ qemu_set_fd_write_handler(fd, write, o)/ s/qemu_set_fd_handler2(fd, NULL, NULL, write, o)/ qemu_set_fd_write_handler(fd, write, o)/ Signed-off-by: Juan Quintela --- audio/alsaaudio.c | 4 ++-- audio/ossaudio.c | 2 +- migration-tcp.c | 2 +- migration-unix.c | 2 +- migration.c | 2 +- net/socket.c | 2 +- qemu-char.h | 4 +++- usb-linux.c | 2 +- vl.c | 11 +++++++++++ vnc-auth-vencrypt.c | 2 +- 10 files changed, 23 insertions(+), 10 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 2455ee4..894f02b 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -273,8 +273,8 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask) if (conf.verbose) { dolog ("POLLOUT %d %d\n", i, pfds[i].fd); } - err = qemu_set_fd_handler (pfds[i].fd, NULL, - alsa_poll_handler, hlp); + err = qemu_set_fd_write_handler (pfds[i].fd, alsa_poll_handler, + hlp); } if (conf.verbose) { dolog ("Set handler events=%#x index=%d fd=%d err=%d\n", diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 4c91a46..4d0cd36 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -146,7 +146,7 @@ static int oss_poll_out (HWVoiceOut *hw) { OSSVoiceOut *oss = (OSSVoiceOut *) hw; - return qemu_set_fd_handler (oss->fd, NULL, oss_helper_poll_out, NULL); + return qemu_set_fd_write_handler (oss->fd, oss_helper_poll_out, NULL); } static int oss_poll_in (HWVoiceIn *hw) diff --git a/migration-tcp.c b/migration-tcp.c index 66f126f..c141322 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -123,7 +123,7 @@ MigrationState *tcp_start_outgoing_migration(Monitor *mon, ret = -(s->get_error(s)); if (ret == -EINPROGRESS || ret == -EWOULDBLOCK) - qemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s); + qemu_set_fd_write_handler(s->fd, tcp_wait_for_connect, s); } while (ret == -EINTR); if (ret < 0 && ret != -EINPROGRESS && ret != -EWOULDBLOCK) { diff --git a/migration-unix.c b/migration-unix.c index fe9a820..b50ccb2 100644 --- a/migration-unix.c +++ b/migration-unix.c @@ -118,7 +118,7 @@ MigrationState *unix_start_outgoing_migration(Monitor *mon, ret = -(s->get_error(s)); if (ret == -EINPROGRESS || ret == -EWOULDBLOCK) - qemu_set_fd_handler2(s->fd, NULL, NULL, unix_wait_for_connect, s); + qemu_set_fd_write_handler(s->fd, unix_wait_for_connect, s); } while (ret == -EINTR); if (ret < 0 && ret != -EINPROGRESS && ret != -EWOULDBLOCK) { diff --git a/migration.c b/migration.c index 787147a..c310e4b 100644 --- a/migration.c +++ b/migration.c @@ -332,7 +332,7 @@ ssize_t migrate_fd_put_buffer(void *opaque, const void *data, size_t size) ret = -(s->get_error(s)); if (ret == -EAGAIN) - qemu_set_fd_handler2(s->fd, NULL, NULL, migrate_fd_put_notify, s); + qemu_set_fd_write_handler(s->fd, migrate_fd_put_notify, s); return ret; } diff --git a/net/socket.c b/net/socket.c index 5772202..e746b19 100644 --- a/net/socket.c +++ b/net/socket.c @@ -316,7 +316,7 @@ static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, if (is_connected) { net_socket_connect(s); } else { - qemu_set_fd_handler(s->fd, NULL, net_socket_connect, s); + qemu_set_fd_write_handler(s->fd, net_socket_connect, s); } return s; } diff --git a/qemu-char.h b/qemu-char.h index 70e4bf9..76cacd9 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -110,6 +110,8 @@ int qemu_set_fd_handler(int fd, int qemu_set_fd_read_handler(int fd, IOHandler *fd_read, void *opaque); - +int qemu_set_fd_write_handler(int fd, + IOHandler *fd_read, + void *opaque); #endif diff --git a/usb-linux.c b/usb-linux.c index b7ac3e9..9c871ce 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -940,7 +940,7 @@ static int usb_host_open(USBHostDevice *dev, int bus_num, prod_name); /* USB devio uses 'write' flag to check for async completions */ - qemu_set_fd_handler(dev->fd, NULL, async_complete, dev); + qemu_set_fd_write_handler(dev->fd, async_complete, dev); usb_device_attach(&dev->dev); return 0; diff --git a/vl.c b/vl.c index c855167..6e75347 100644 --- a/vl.c +++ b/vl.c @@ -2665,6 +2665,17 @@ int qemu_set_fd_read_handler(int fd, return qemu_set_fd_handler2(fd, NULL, fd_read, NULL, opaque); } +int qemu_set_fd_write_handler(int fd, + IOHandler *fd_write, + void *opaque) +{ + if(fd_write == NULL) { + fprintf(stderr, "qemu_set_fd_write_handler: NULL write handler\n"); + exit(1); + } + return qemu_set_fd_handler2(fd, NULL, NULL, fd_write, opaque); +} + #ifdef _WIN32 /***********************************************************/ /* Polling handling */ diff --git a/vnc-auth-vencrypt.c b/vnc-auth-vencrypt.c index 2999c2d..7b3fd57 100644 --- a/vnc-auth-vencrypt.c +++ b/vnc-auth-vencrypt.c @@ -73,7 +73,7 @@ static int vnc_start_vencrypt_handshake(struct VncState *vs) { if (!gnutls_record_get_direction(vs->tls.session)) qemu_set_fd_read_handler(vs->csock, vnc_tls_handshake_io, vs); else - qemu_set_fd_handler(vs->csock, NULL, vnc_tls_handshake_io, vs); + qemu_set_fd_write_handler(vs->csock, vnc_tls_handshake_io, vs); return 0; } VNC_DEBUG("Handshake failed %s\n", gnutls_strerror(ret));