diff options
Diffstat (limited to 'chardev')
-rw-r--r-- | chardev/char-fd.c | 5 | ||||
-rw-r--r-- | chardev/char-fe.c | 7 | ||||
-rw-r--r-- | chardev/char-pty.c | 5 | ||||
-rw-r--r-- | chardev/char-socket.c | 7 | ||||
-rw-r--r-- | chardev/char-udp.c | 5 | ||||
-rw-r--r-- | chardev/char.c | 11 |
6 files changed, 22 insertions, 18 deletions
diff --git a/chardev/char-fd.c b/chardev/char-fd.c index 6a62a545f2..2c9b2ce567 100644 --- a/chardev/char-fd.c +++ b/chardev/char-fd.c @@ -84,8 +84,7 @@ static GSource *fd_chr_add_watch(Chardev *chr, GIOCondition cond) return qio_channel_create_watch(s->ioc_out, cond); } -static void fd_chr_update_read_handler(Chardev *chr, - GMainContext *context) +static void fd_chr_update_read_handler(Chardev *chr) { FDChardev *s = FD_CHARDEV(chr); @@ -94,7 +93,7 @@ static void fd_chr_update_read_handler(Chardev *chr, chr->gsource = io_add_watch_poll(chr, s->ioc_in, fd_chr_read_poll, fd_chr_read, chr, - context); + chr->gcontext); } } diff --git a/chardev/char-fe.c b/chardev/char-fe.c index f3af6ae584..ee6d596100 100644 --- a/chardev/char-fe.c +++ b/chardev/char-fe.c @@ -253,7 +253,6 @@ void qemu_chr_fe_set_handlers(CharBackend *b, bool set_open) { Chardev *s; - ChardevClass *cc; int fe_open; s = b->chr; @@ -261,7 +260,6 @@ void qemu_chr_fe_set_handlers(CharBackend *b, return; } - cc = CHARDEV_GET_CLASS(s); if (!opaque && !fd_can_read && !fd_read && !fd_event) { fe_open = 0; remove_fd_in_watch(s); @@ -273,9 +271,8 @@ void qemu_chr_fe_set_handlers(CharBackend *b, b->chr_event = fd_event; b->chr_be_change = be_change; b->opaque = opaque; - if (cc->chr_update_read_handler) { - cc->chr_update_read_handler(s, context); - } + + qemu_chr_be_update_read_handlers(s, context); if (set_open) { qemu_chr_fe_set_open(b, fe_open); diff --git a/chardev/char-pty.c b/chardev/char-pty.c index e5d20a0e6a..761ae6dec1 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -112,8 +112,7 @@ static void pty_chr_update_read_handler_locked(Chardev *chr) } } -static void pty_chr_update_read_handler(Chardev *chr, - GMainContext *context) +static void pty_chr_update_read_handler(Chardev *chr) { qemu_mutex_lock(&chr->chr_write_lock); pty_chr_update_read_handler_locked(chr); @@ -219,7 +218,7 @@ static void pty_chr_state(Chardev *chr, int connected) chr->gsource = io_add_watch_poll(chr, s->ioc, pty_chr_read_poll, pty_chr_read, - chr, NULL); + chr, chr->gcontext); } } } diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 1ae730a4cb..e65148fe97 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -516,13 +516,12 @@ static void tcp_chr_connect(void *opaque) chr->gsource = io_add_watch_poll(chr, s->ioc, tcp_chr_read_poll, tcp_chr_read, - chr, NULL); + chr, chr->gcontext); } qemu_chr_be_event(chr, CHR_EVENT_OPENED); } -static void tcp_chr_update_read_handler(Chardev *chr, - GMainContext *context) +static void tcp_chr_update_read_handler(Chardev *chr) { SocketChardev *s = SOCKET_CHARDEV(chr); @@ -535,7 +534,7 @@ static void tcp_chr_update_read_handler(Chardev *chr, chr->gsource = io_add_watch_poll(chr, s->ioc, tcp_chr_read_poll, tcp_chr_read, chr, - context); + chr->gcontext); } } diff --git a/chardev/char-udp.c b/chardev/char-udp.c index 4ee11d3ebf..d46ff7ab53 100644 --- a/chardev/char-udp.c +++ b/chardev/char-udp.c @@ -100,8 +100,7 @@ static gboolean udp_chr_read(QIOChannel *chan, GIOCondition cond, void *opaque) return TRUE; } -static void udp_chr_update_read_handler(Chardev *chr, - GMainContext *context) +static void udp_chr_update_read_handler(Chardev *chr) { UdpChardev *s = UDP_CHARDEV(chr); @@ -110,7 +109,7 @@ static void udp_chr_update_read_handler(Chardev *chr, chr->gsource = io_add_watch_poll(chr, s->ioc, udp_chr_read_poll, udp_chr_read, chr, - context); + chr->gcontext); } } diff --git a/chardev/char.c b/chardev/char.c index b6fd5eb6a6..2ae4f465ec 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -180,6 +180,17 @@ void qemu_chr_be_write(Chardev *s, uint8_t *buf, int len) } } +void qemu_chr_be_update_read_handlers(Chardev *s, + GMainContext *context) +{ + ChardevClass *cc = CHARDEV_GET_CLASS(s); + + s->gcontext = context; + if (cc->chr_update_read_handler) { + cc->chr_update_read_handler(s); + } +} + int qemu_chr_add_client(Chardev *s, int fd) { return CHARDEV_GET_CLASS(s)->chr_add_client ? |