Skip to content

Commit

Permalink
chardev: new qemu_chr_be_update_read_handlers()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
xzpeter authored and bonzini committed Sep 22, 2017
1 parent 9bad2a6 commit 07241c2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
7 changes: 2 additions & 5 deletions chardev/char-fe.c
Expand Up @@ -253,15 +253,13 @@ void qemu_chr_fe_set_handlers(CharBackend *b,
bool set_open)
{
Chardev *s;
ChardevClass *cc;
int fe_open;

s = b->chr;
if (!s) {
return;
}

cc = CHARDEV_GET_CLASS(s);
if (!opaque && !fd_can_read && !fd_read && !fd_event) {
fe_open = 0;
remove_fd_in_watch(s);
Expand All @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions chardev/char.c
Expand Up @@ -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 ?
Expand Down
10 changes: 10 additions & 0 deletions include/chardev/char.h
Expand Up @@ -168,6 +168,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:
*
Expand Down

0 comments on commit 07241c2

Please sign in to comment.