Patch consist: s/qemu_set_fd_handler2(fd, NULL, NULL, NULL, NULL)/qemu_clear_fd_handler(fd)/ s/qemu_set_fd_handler(fd, NULL, NULL, NULL)/qemu_clear_fd_handler(fd)/
Signed-off-by: Juan Quintela <quint...@redhat.com> --- audio/alsaaudio.c | 4 ++-- audio/ossaudio.c | 6 +++--- hw/xen_backend.c | 4 ++-- migration-exec.c | 2 +- migration-fd.c | 2 +- migration-tcp.c | 4 ++-- migration-unix.c | 4 ++-- migration.c | 6 +++--- net/socket.c | 6 +++--- net/vde.c | 2 +- qemu-char.c | 22 +++++++++++----------- qemu-char.h | 1 + usb-linux.c | 2 +- vl.c | 19 +++++++++++++------ vnc.c | 4 ++-- 15 files changed, 48 insertions(+), 40 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 88344ff..4259d9c 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -134,7 +134,7 @@ static void alsa_fini_poll (struct pollhlp *hlp) if (pfds) { for (i = 0; i < hlp->count; ++i) { - qemu_set_fd_handler (pfds[i].fd, NULL, NULL, NULL); + qemu_clear_fd_handler (pfds[i].fd); } qemu_free (pfds); } @@ -286,7 +286,7 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask) pfds[i].events, i, pfds[i].fd, err); while (i--) { - qemu_set_fd_handler (pfds[i].fd, NULL, NULL, NULL); + qemu_clear_fd_handler (pfds[i].fd); } qemu_free (pfds); return -1; diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 42bffae..97e0f1b 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -122,7 +122,7 @@ static void oss_anal_close (int *fdp) { int err; - qemu_set_fd_handler (*fdp, NULL, NULL, NULL); + qemu_clear_fd_handler (*fdp); err = close (*fdp); if (err) { oss_logerr (errno, "Failed to close file(fd=%d)\n", *fdp); @@ -651,7 +651,7 @@ static int oss_ctl_out (HWVoiceOut *hw, int cmd, ...) case VOICE_DISABLE: if (hw->poll_mode) { - qemu_set_fd_handler (oss->fd, NULL, NULL, NULL); + qemu_clear_fd_handler (oss->fd); hw->poll_mode = 0; } @@ -835,7 +835,7 @@ static int oss_ctl_in (HWVoiceIn *hw, int cmd, ...) case VOICE_DISABLE: if (hw->poll_mode) { hw->poll_mode = 0; - qemu_set_fd_handler (oss->fd, NULL, NULL, NULL); + qemu_clear_fd_handler (oss->fd); } break; } diff --git a/hw/xen_backend.c b/hw/xen_backend.c index a2e408f..2eec0c6 100644 --- a/hw/xen_backend.c +++ b/hw/xen_backend.c @@ -635,7 +635,7 @@ int xen_be_init(void) return 0; err: - qemu_set_fd_handler(xs_fileno(xenstore), NULL, NULL, NULL); + qemu_clear_fd_handler(xs_fileno(xenstore)); xs_daemon_close(xenstore); xenstore = NULL; @@ -667,7 +667,7 @@ void xen_be_unbind_evtchn(struct XenDevice *xendev) { if (xendev->local_port == -1) return; - qemu_set_fd_handler(xc_evtchn_fd(xendev->evtchndev), NULL, NULL, NULL); + qemu_clear_fd_handler(xc_evtchn_fd(xendev->evtchndev)); xc_evtchn_unbind(xendev->evtchndev, xendev->local_port); xen_be_printf(xendev, 2, "unbind evtchn port %d\n", xendev->local_port); xendev->local_port = -1; diff --git a/migration-exec.c b/migration-exec.c index 3edc026..7e2ac0e 100644 --- a/migration-exec.c +++ b/migration-exec.c @@ -121,7 +121,7 @@ static void exec_accept_incoming_migration(void *opaque) qemu_announce_self(); DPRINTF("successfully loaded vm state\n"); /* we've successfully migrated, close the fd */ - qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(qemu_stdio_fd(f)); if (autostart) vm_start(); diff --git a/migration-fd.c b/migration-fd.c index 0cc74ad..056ac3e 100644 --- a/migration-fd.c +++ b/migration-fd.c @@ -114,7 +114,7 @@ static void fd_accept_incoming_migration(void *opaque) qemu_announce_self(); DPRINTF("successfully loaded vm state\n"); /* we've successfully migrated, close the fd */ - qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(qemu_stdio_fd(f)); if (autostart) vm_start(); diff --git a/migration-tcp.c b/migration-tcp.c index e7f307c..d542804 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -66,7 +66,7 @@ static void tcp_wait_for_connect(void *opaque) return; } - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(s->fd); if (val == 0) migrate_fd_connect(s); @@ -171,7 +171,7 @@ static void tcp_accept_incoming_migration(void *opaque) DPRINTF("successfully loaded vm state\n"); /* we've successfully migrated, close the server socket */ - qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(s); close(s); if (autostart) vm_start(); diff --git a/migration-unix.c b/migration-unix.c index b7aab38..44427f8 100644 --- a/migration-unix.c +++ b/migration-unix.c @@ -65,7 +65,7 @@ static void unix_wait_for_connect(void *opaque) return; } - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(s->fd); if (val == 0) migrate_fd_connect(s); @@ -177,7 +177,7 @@ static void unix_accept_incoming_migration(void *opaque) DPRINTF("successfully loaded vm state\n"); /* we've successfully migrated, close the server socket */ - qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(s); close(s); out_fopen: diff --git a/migration.c b/migration.c index 05f6cc5..787147a 100644 --- a/migration.c +++ b/migration.c @@ -292,7 +292,7 @@ void migrate_fd_error(FdMigrationState *s) void migrate_fd_cleanup(FdMigrationState *s) { - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(s->fd); if (s->file) { DPRINTF("closing file\n"); @@ -315,7 +315,7 @@ void migrate_fd_put_notify(void *opaque) { FdMigrationState *s = opaque; - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(s->fd); qemu_file_put_notify(s->file); } @@ -449,6 +449,6 @@ int migrate_fd_close(void *opaque) { FdMigrationState *s = opaque; - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(s->fd); return s->close(s); } diff --git a/net/socket.c b/net/socket.c index 442a9c7..b7a21f8 100644 --- a/net/socket.c +++ b/net/socket.c @@ -84,7 +84,7 @@ static void net_socket_send(void *opaque) } else if (size == 0) { /* end of connection */ eoc: - qemu_set_fd_handler(s->fd, NULL, NULL, NULL); + qemu_clear_fd_handler(s->fd); closesocket(s->fd); return; } @@ -143,7 +143,7 @@ static void net_socket_send_dgram(void *opaque) return; if (size == 0) { /* end of connection */ - qemu_set_fd_handler(s->fd, NULL, NULL, NULL); + qemu_clear_fd_handler(s->fd); return; } qemu_send_packet(&s->nc, s->buf, size); @@ -212,7 +212,7 @@ fail: static void net_socket_cleanup(VLANClientState *nc) { NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc); - qemu_set_fd_handler(s->fd, NULL, NULL, NULL); + qemu_clear_fd_handler(s->fd); close(s->fd); } diff --git a/net/vde.c b/net/vde.c index 0b46fa6..fc75e8f 100644 --- a/net/vde.c +++ b/net/vde.c @@ -65,7 +65,7 @@ static ssize_t vde_receive(VLANClientState *nc, const uint8_t *buf, size_t size) static void vde_cleanup(VLANClientState *nc) { VDEState *s = DO_UPCAST(VDEState, nc, nc); - qemu_set_fd_handler(vde_datafd(s->vde), NULL, NULL, NULL); + qemu_clear_fd_handler(vde_datafd(s->vde)); vde_close(s->vde); } diff --git a/qemu-char.c b/qemu-char.c index 86c7c5a..a87e4e7 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -560,7 +560,7 @@ static void fd_chr_read(void *opaque) size = read(s->fd_in, buf, len); if (size == 0) { /* FD has been closed. Remove it from the active list. */ - qemu_set_fd_handler2(s->fd_in, NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(s->fd_in); qemu_chr_event(chr, CHR_EVENT_CLOSED); return; } @@ -589,7 +589,7 @@ static void fd_chr_close(struct CharDriverState *chr) if (s->fd_in >= 0) { if (display_type == DT_NOGRAPHIC && s->fd_in == 0) { } else { - qemu_set_fd_handler2(s->fd_in, NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(s->fd_in); } } @@ -689,7 +689,7 @@ static void stdio_read(void *opaque) size = read(0, buf, 1); if (size == 0) { /* stdin has been closed. Remove it from the active list. */ - qemu_set_fd_handler2(0, NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(0); qemu_chr_event(chr, CHR_EVENT_CLOSED); return; } @@ -745,7 +745,7 @@ static void qemu_chr_close_stdio(struct CharDriverState *chr) { term_exit(); stdio_nb_clients--; - qemu_set_fd_handler2(0, NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(0); fd_chr_close(chr); } @@ -904,7 +904,7 @@ static void pty_chr_state(CharDriverState *chr, int connected) PtyCharDriver *s = chr->opaque; if (!connected) { - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(s->fd); s->connected = 0; s->polling = 0; /* (re-)connect poll interval for idle guests: once per second. @@ -940,7 +940,7 @@ static void pty_chr_close(struct CharDriverState *chr) { PtyCharDriver *s = chr->opaque; - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(s->fd); close(s->fd); qemu_del_timer(s->timer); qemu_free_timer(s->timer); @@ -1840,7 +1840,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_clear_fd_handler(s->fd); closesocket(s->fd); } qemu_free(s); @@ -2050,7 +2050,7 @@ static void tcp_chr_read(void *opaque) if (s->listen_fd >= 0) { qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, chr); } - qemu_set_fd_handler(s->fd, NULL, NULL, NULL); + qemu_clear_fd_handler(s->fd); closesocket(s->fd); s->fd = -1; qemu_chr_event(chr, CHR_EVENT_CLOSED); @@ -2134,7 +2134,7 @@ static void tcp_chr_accept(void *opaque) if (s->do_nodelay) socket_set_nodelay(fd); s->fd = fd; - qemu_set_fd_handler(s->listen_fd, NULL, NULL, NULL); + qemu_clear_fd_handler(s->listen_fd); tcp_chr_connect(chr); } @@ -2142,11 +2142,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_clear_fd_handler(s->fd); closesocket(s->fd); } if (s->listen_fd >= 0) { - qemu_set_fd_handler(s->listen_fd, NULL, NULL, NULL); + qemu_clear_fd_handler(s->listen_fd); closesocket(s->listen_fd); } qemu_free(s); diff --git a/qemu-char.h b/qemu-char.h index bcc0766..23305a8 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -97,6 +97,7 @@ extern int term_escape_char; /* async I/O support */ +int qemu_clear_fd_handler(int fd); int qemu_set_fd_handler2(int fd, IOCanRWHandler *fd_read_poll, IOHandler *fd_read, diff --git a/usb-linux.c b/usb-linux.c index a9c15c6..b7ac3e9 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -957,7 +957,7 @@ static int usb_host_close(USBHostDevice *dev) if (dev->fd == -1) return -1; - qemu_set_fd_handler(dev->fd, NULL, NULL, NULL); + qemu_clear_fd_handler(dev->fd); dev->closing = 1; async_complete(dev); dev->closing = 0; diff --git a/vl.c b/vl.c index 83ff652..2d364bb 100644 --- a/vl.c +++ b/vl.c @@ -2603,6 +2603,18 @@ typedef struct IOHandlerRecord { static QTAILQ_HEAD(, IOHandlerRecord) io_handlers = QTAILQ_HEAD_INITIALIZER(io_handlers); +int qemu_clear_fd_handler(int fd) +{ + IOHandlerRecord *ioh; + + QTAILQ_FOREACH(ioh, &io_handlers, next) { + if (ioh->fd == fd) { + ioh->deleted = 1; + break; + } + } + return 0; +} /* XXX: fd_read_poll should be suppressed, but an API change is necessary in the character devices to suppress fd_can_read(). */ @@ -2615,12 +2627,7 @@ int qemu_set_fd_handler2(int fd, IOHandlerRecord *ioh; if (!fd_read && !fd_write) { - QTAILQ_FOREACH(ioh, &io_handlers, next) { - if (ioh->fd == fd) { - ioh->deleted = 1; - break; - } - } + qemu_clear_fd_handler(fd); } else { QTAILQ_FOREACH(ioh, &io_handlers, next) { if (ioh->fd == fd) diff --git a/vnc.c b/vnc.c index 01353a9..d15a984 100644 --- a/vnc.c +++ b/vnc.c @@ -1076,7 +1076,7 @@ static void vnc_disconnect_start(VncState *vs) { if (vs->csock == -1) return; - qemu_set_fd_handler2(vs->csock, NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(vs->csock); closesocket(vs->csock); vs->csock = -1; } @@ -2475,7 +2475,7 @@ void vnc_display_close(DisplayState *ds) vs->display = NULL; } if (vs->lsock != -1) { - qemu_set_fd_handler2(vs->lsock, NULL, NULL, NULL, NULL); + qemu_clear_fd_handler(vs->lsock); close(vs->lsock); vs->lsock = -1; } -- 1.6.6.1