diff options
author | Peter Xu <peterx@redhat.com> | 2017-09-21 14:35:51 +0800 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2017-09-22 21:07:27 +0200 |
commit | 07241c205c2c0b3e5e17e883c8ae523e90d172c2 (patch) | |
tree | 87fe7df7a38164e32c8c9b5aed0db5c61ed6719e | |
parent | 9bad2a6b9d0aeb2dcf91a07652cc63bbb6e73141 (diff) |
chardev: new qemu_chr_be_update_read_handlers()
Add a wrapper for the chr_update_read_handler().
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <1505975754-21555-2-git-send-email-peterx@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | chardev/char-fe.c | 7 | ||||
-rw-r--r-- | chardev/char.c | 10 | ||||
-rw-r--r-- | include/chardev/char.h | 10 |
3 files changed, 22 insertions, 5 deletions
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.c b/chardev/char.c index b6fd5eb6a6..e090dd5a27 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -180,6 +180,16 @@ 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); + + if (cc->chr_update_read_handler) { + cc->chr_update_read_handler(s, context); + } +} + int qemu_chr_add_client(Chardev *s, int fd) { return CHARDEV_GET_CLASS(s)->chr_add_client ? diff --git a/include/chardev/char.h b/include/chardev/char.h index 66dde4637e..2068ea496d 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -169,6 +169,16 @@ void qemu_chr_be_write(Chardev *s, uint8_t *buf, int len); void qemu_chr_be_write_impl(Chardev *s, uint8_t *buf, int len); /** + * @qemu_chr_be_update_read_handlers: + * + * Invoked when frontend read handlers are setup + * + * @context the gcontext that will be used to attach the watch sources + */ +void qemu_chr_be_update_read_handlers(Chardev *s, + GMainContext *context); + +/** * @qemu_chr_be_event: * * Send an event from the back end to the front end. |