aboutsummaryrefslogtreecommitdiff
path: root/include/chardev
diff options
context:
space:
mode:
authorPeter Xu <peterx@redhat.com>2018-01-04 22:18:35 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2018-01-12 13:22:02 +0100
commit2c716ba1506769c9be2caa02f0f6d6e7c00f4304 (patch)
tree233189ca8b845f83871b104d50dcdedcb264484c /include/chardev
parent938eb9e9c83d34d90cac6ec5c5388e7998840e4e (diff)
chardev: introduce qemu_chr_timeout_add_ms()
It's a replacement of g_timeout_add[_seconds]() for chardevs. Chardevs now can have dedicated gcontext, we should always bind chardev tasks onto those gcontext rather than the default main context. Since there are quite a few of g_timeout_add[_seconds]() callers, a new function qemu_chr_timeout_add_ms() is introduced. One thing to mention is that, terminal3270 is still always running on main gcontext. However let's convert that as well since it's still part of chardev codes and in case one day we'll miss that when we move it out of main gcontext too. Also, convert all the timers from GSource tags into GSource pointers. Gsource tag IDs and g_source_remove()s can only work with default gcontext, while now these GSources can logically be attached to other contexts. So let's use explicit g_source_destroy() plus another g_source_unref() to remove a timer. Note: when in the timer handler, we don't need the g_source_destroy() any more since that'll be done automatically if the timer handler returns false (and that's what all the current handlers do). Yet another note: in pty_chr_rearm_timer() we take special care for ms=1000. This patch merged the two cases into one. Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <20180104141835.17987-4-peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/chardev')
-rw-r--r--include/chardev/char.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/chardev/char.h b/include/chardev/char.h
index 778d610295..d8941fcbb1 100644
--- a/include/chardev/char.h
+++ b/include/chardev/char.h
@@ -256,6 +256,9 @@ Chardev *qemu_chardev_new(const char *id, const char *typename,
extern int term_escape_char;
+GSource *qemu_chr_timeout_add_ms(Chardev *chr, guint ms,
+ GSourceFunc func, void *private);
+
/* console.c */
void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, Error **errp);