@@ -266,8 +266,8 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask)
for (i = 0; i < count; ++i) {
if (pfds[i].events & POLLIN) {
- err = qemu_set_fd_handler (pfds[i].fd, alsa_poll_handler,
- NULL, hlp);
+ err = qemu_set_fd_read_handler (pfds[i].fd, alsa_poll_handler,
+ hlp);
}
if (pfds[i].events & POLLOUT) {
if (conf.verbose) {
@@ -153,7 +153,7 @@ static int oss_poll_in (HWVoiceIn *hw)
{
OSSVoiceIn *oss = (OSSVoiceIn *) hw;
- return qemu_set_fd_handler (oss->fd, oss_helper_poll_in, NULL, NULL);
+ return qemu_set_fd_read_handler (oss->fd, oss_helper_poll_in, NULL);
}
static int oss_write (SWVoiceOut *sw, void *buf, int len)
@@ -164,5 +164,5 @@ void bt_vhci_init(struct HCIInfo *info)
s->info->evt_recv = vhci_out_hci_packet_event;
s->info->acl_recv = vhci_out_hci_packet_acl;
- qemu_set_fd_handler(s->fd, vhci_read, NULL, s);
+ qemu_set_fd_read_handler(s->fd, vhci_read, s);
}
@@ -612,7 +612,7 @@ CharDriverState *chr_baum_init(QemuOpts *opts)
goto fail;
}
- qemu_set_fd_handler(baum->brlapi_fd, baum_chr_read, NULL, baum);
+ qemu_set_fd_read_handler(baum->brlapi_fd, baum_chr_read, baum);
qemu_chr_generic_open(chr);
@@ -624,7 +624,7 @@ int xen_be_init(void)
return -1;
}
- if (qemu_set_fd_handler(xs_fileno(xenstore), xenstore_update, NULL, NULL) < 0)
+ if (qemu_set_fd_read_handler(xs_fileno(xenstore), xenstore_update, NULL) < 0)
goto err;
xen_xc = xc_interface_open();
@@ -658,8 +658,8 @@ int xen_be_bind_evtchn(struct XenDevice *xendev)
return -1;
}
xen_be_printf(xendev, 2, "bind evtchn port %d\n", xendev->local_port);
- qemu_set_fd_handler(xc_evtchn_fd(xendev->evtchndev),
- xen_be_evtchn_event, NULL, xendev);
+ qemu_set_fd_read_handler(xc_evtchn_fd(xendev->evtchndev),
+ xen_be_evtchn_event, xendev);
return 0;
}
@@ -140,9 +140,9 @@ int exec_start_incoming_migration(const char *command)
return -errno;
}
- qemu_set_fd_handler2(qemu_stdio_fd(f), NULL,
- exec_accept_incoming_migration, NULL,
- (void *)(unsigned long)f);
+ qemu_set_fd_read_handler(qemu_stdio_fd(f),
+ exec_accept_incoming_migration,
+ (void *)(unsigned long)f);
return 0;
}
@@ -136,8 +136,8 @@ int fd_start_incoming_migration(const char *infd)
return -errno;
}
- qemu_set_fd_handler2(fd, NULL, fd_accept_incoming_migration, NULL,
- (void *)(unsigned long)f);
+ qemu_set_fd_read_handler(fd, fd_accept_incoming_migration,
+ (void *)(unsigned long)f);
return 0;
}
@@ -206,8 +206,8 @@ int tcp_start_incoming_migration(const char *host_port)
if (listen(s, 1) == -1)
goto err;
- qemu_set_fd_handler2(s, NULL, tcp_accept_incoming_migration, NULL,
- (void *)(unsigned long)s);
+ qemu_set_fd_read_handler(s, tcp_accept_incoming_migration,
+ (void *)(unsigned long)s);
return 0;
@@ -213,8 +213,8 @@ int unix_start_incoming_migration(const char *path)
goto err;
}
- qemu_set_fd_handler2(sock, NULL, unix_accept_incoming_migration, NULL,
- (void *)(unsigned long)sock);
+ qemu_set_fd_read_handler(sock, unix_accept_incoming_migration,
+ (void *)(unsigned long)sock);
return 0;
@@ -276,7 +276,7 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan,
s->fd = fd;
- qemu_set_fd_handler(s->fd, net_socket_send_dgram, NULL, s);
+ qemu_set_fd_read_handler(s->fd, net_socket_send_dgram, s);
/* mcast: save bound address as dst */
if (is_connected) s->dgram_dst=saddr;
@@ -287,7 +287,7 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan,
static void net_socket_connect(void *opaque)
{
NetSocketState *s = opaque;
- qemu_set_fd_handler(s->fd, net_socket_send, NULL, s);
+ qemu_set_fd_read_handler(s->fd, net_socket_send, s);
}
static NetClientInfo net_socket_info = {
@@ -411,7 +411,7 @@ static int net_socket_listen_init(VLANState *vlan,
s->model = qemu_strdup(model);
s->name = name ? qemu_strdup(name) : NULL;
s->fd = fd;
- qemu_set_fd_handler(fd, net_socket_accept, NULL, s);
+ qemu_set_fd_read_handler(fd, net_socket_accept, s);
return 0;
}
@@ -106,7 +106,7 @@ static int net_vde_init(VLANState *vlan, const char *model,
s->vde = vde;
- qemu_set_fd_handler(vde_datafd(s->vde), vde_to_qemu, NULL, s);
+ qemu_set_fd_read_handler(vde_datafd(s->vde), vde_to_qemu, s);
return 0;
}
@@ -2048,7 +2048,7 @@ 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_read_handler(s->listen_fd, tcp_chr_accept, chr);
}
qemu_clear_fd_handler(s->fd);
closesocket(s->fd);
@@ -2208,7 +2208,7 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts *opts)
if (is_listen) {
s->listen_fd = fd;
- qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, chr);
+ qemu_set_fd_read_handler(s->listen_fd, tcp_chr_accept, chr);
if (is_telnet)
s->do_telnetopt = 1;
@@ -107,5 +107,9 @@ int qemu_set_fd_handler(int fd,
IOHandler *fd_read,
IOHandler *fd_write,
void *opaque);
+int qemu_set_fd_read_handler(int fd,
+ IOHandler *fd_read,
+ void *opaque);
+
#endif
@@ -2654,6 +2654,17 @@ int qemu_set_fd_handler(int fd,
return qemu_set_fd_handler2(fd, NULL, fd_read, fd_write, opaque);
}
+int qemu_set_fd_read_handler(int fd,
+ IOHandler *fd_read,
+ void *opaque)
+{
+ if(fd_read == NULL) {
+ fprintf(stderr, "qemu_set_fd_read_handler: NULL read handler\n");
+ exit(1);
+ }
+ return qemu_set_fd_handler2(fd, NULL, fd_read, NULL, opaque);
+}
+
#ifdef _WIN32
/***********************************************************/
/* Polling handling */
@@ -3259,8 +3270,8 @@ static int qemu_event_init(void)
if (err < 0)
goto fail;
- qemu_set_fd_handler2(fds[0], NULL, qemu_event_read, NULL,
- (void *)(unsigned long)fds[0]);
+ qemu_set_fd_read_handler(fds[0], qemu_event_read,
+ (void *)(unsigned long)fds[0]);
io_thread_fd = fds[1];
return 0;
@@ -83,7 +83,7 @@ long vnc_client_write_sasl(VncState *vs)
* SASL encoded output
*/
if (vs->output.offset == 0) {
- qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, NULL, vs);
+ qemu_set_fd_read_handler(vs->csock, vnc_client_read, vs);
}
return ret;
@@ -71,7 +71,7 @@ static int vnc_start_vencrypt_handshake(struct VncState *vs) {
if (!gnutls_error_is_fatal(ret)) {
VNC_DEBUG("Handshake interrupted (blocking)\n");
if (!gnutls_record_get_direction(vs->tls.session))
- qemu_set_fd_handler(vs->csock, vnc_tls_handshake_io, NULL, vs);
+ 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);
return 0;
@@ -1218,7 +1218,7 @@ static long vnc_client_write_plain(VncState *vs)
vs->output.offset -= ret;
if (vs->output.offset == 0) {
- qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, NULL, vs);
+ qemu_set_fd_read_handler(vs->csock, vnc_client_read, vs);
}
return ret;
@@ -2389,7 +2389,7 @@ static void vnc_connect(VncDisplay *vd, int csock)
VNC_DEBUG("New client on socket %d\n", csock);
dcl->idle = 0;
socket_set_nonblock(vs->csock);
- qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, NULL, vs);
+ qemu_set_fd_read_handler(vs->csock, vnc_client_read, vs);
vnc_client_cache_addr(vs);
vnc_qmp_event(vs, QEVENT_VNC_CONNECTED);
@@ -2730,5 +2730,5 @@ int vnc_display_open(DisplayState *ds, const char *display)
vs->display = dpy;
}
}
- return qemu_set_fd_handler2(vs->lsock, NULL, vnc_listen_read, NULL, vs);
+ return qemu_set_fd_read_handler(vs->lsock, vnc_listen_read, vs);
}
Patch consist: s/qemu_set_fd_handler(fd, read, NULL, o)/ qemu_set_fd_read_handler(fd, read, o)/ s/qemu_set_fd_handler2(fd, NULL, read, NULL, o)/ qemu_set_fd_read_handler(fd, read, o)/ Signed-off-by: Juan Quintela <quintela@redhat.com> --- audio/alsaaudio.c | 4 ++-- audio/ossaudio.c | 2 +- bt-vhci.c | 2 +- hw/baum.c | 2 +- hw/xen_backend.c | 6 +++--- migration-exec.c | 6 +++--- migration-fd.c | 4 ++-- migration-tcp.c | 4 ++-- migration-unix.c | 4 ++-- net/socket.c | 6 +++--- net/vde.c | 2 +- qemu-char.c | 4 ++-- qemu-char.h | 4 ++++ vl.c | 15 +++++++++++++-- vnc-auth-sasl.c | 2 +- vnc-auth-vencrypt.c | 2 +- vnc.c | 6 +++--- 17 files changed, 45 insertions(+), 30 deletions(-)