diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2016-10-22 12:53:01 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-10-24 15:46:10 +0200 |
commit | a4afa548fc6dd9842ed86639b4d37d4d1c4ad480 (patch) | |
tree | 94f8e8304a29960fa03001cd3d57b75c600becd8 /include | |
parent | ea3af47d75335d9247dfa33554ddd935957f77cd (diff) | |
download | qemu-a4afa548fc6dd9842ed86639b4d37d4d1c4ad480.zip qemu-a4afa548fc6dd9842ed86639b4d37d4d1c4ad480.tar.gz qemu-a4afa548fc6dd9842ed86639b4d37d4d1c4ad480.tar.bz2 |
char: move front end handlers in CharBackend
Since the hanlders are associated with a CharBackend, rather than the
CharDriverState, it is more appropriate to store in CharBackend. This
avoids the handler copy dance in qemu_chr_fe_set_handlers() then
mux_chr_update_read_handler(), by storing the CharBackend pointer
directly.
Also a mux CharDriver should go through mux->backends[focused], since
chr->be will stay NULL. Before that, it was possible to call
chr->handler by mistake with surprising results, for ex through
qemu_chr_be_can_write(), which would result in calling the last set
handler front end, not the one with focus.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20161022095318.17775-22-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/sysemu/char.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/include/sysemu/char.h b/include/sysemu/char.h index 2f60a10..7187c3e 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -76,6 +76,10 @@ typedef enum { * CharDriverState */ typedef struct CharBackend { CharDriverState *chr; + IOEventHandler *chr_event; + IOCanReadHandler *chr_can_read; + IOReadHandler *chr_read; + void *opaque; int tag; } CharBackend; @@ -86,22 +90,19 @@ struct CharDriverState { const uint8_t *buf, int len); GSource *(*chr_add_watch)(struct CharDriverState *s, GIOCondition cond); void (*chr_update_read_handler)(struct CharDriverState *s, - GMainContext *context, int tag); + GMainContext *context); int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg); int (*get_msgfds)(struct CharDriverState *s, int* fds, int num); int (*set_msgfds)(struct CharDriverState *s, int *fds, int num); int (*chr_add_client)(struct CharDriverState *chr, int fd); int (*chr_wait_connected)(struct CharDriverState *chr, Error **errp); - IOEventHandler *chr_event; - IOCanReadHandler *chr_can_read; - IOReadHandler *chr_read; - void *handler_opaque; void (*chr_close)(struct CharDriverState *chr); void (*chr_disconnect)(struct CharDriverState *chr); void (*chr_accept_input)(struct CharDriverState *chr); void (*chr_set_echo)(struct CharDriverState *chr, bool echo); void (*chr_set_fe_open)(struct CharDriverState *chr, int fe_open); void (*chr_fe_event)(struct CharDriverState *chr, int event); + CharBackend *be; void *opaque; char *label; char *filename; |