On Thu, Dec 28, 2017 at 8:29 AM, Peter Xu <pet...@redhat.com> wrote: > The idle task will be attached to main gcontext even if the chardev > backend is running in another gcontext. Fix the only caller by > extending the g_idle_add() logic into the more powerful > g_source_attach(). It's basically g_idle_add_full() implementation, but > with the chardev's gcontext passed in. > > Signed-off-by: Peter Xu <pet...@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lur...@redhat.com> > --- > chardev/char-pty.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/chardev/char-pty.c b/chardev/char-pty.c > index 761ae6dec1..dd17b1b823 100644 > --- a/chardev/char-pty.c > +++ b/chardev/char-pty.c > @@ -210,9 +210,14 @@ static void pty_chr_state(Chardev *chr, int connected) > s->timer_tag = 0; > } > if (!s->connected) { > + GSource *source = g_idle_source_new(); > + > g_assert(s->open_tag == 0); > s->connected = 1; > - s->open_tag = g_idle_add(qemu_chr_be_generic_open_func, chr); > + g_source_set_callback(source, qemu_chr_be_generic_open_func, > + chr, NULL); > + s->open_tag = g_source_attach(source, chr->gcontext); > + g_source_unref(source); > } > if (!chr->gsource) { > chr->gsource = io_add_watch_poll(chr, s->ioc, > -- > 2.14.3 > > -- Marc-André Lureau