From 95a3ced4c37a6cfd35a5a699db0c3ae21f21272a Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Tue, 2 Jun 2020 21:41:00 -0700 Subject: [PATCH] chardev: Default to qemu_main_context In the event chardevs are created outside of the main QEMU thread, but are using the default context specified by `NULL`, take care to explicitly use the `qemu_main_context` context. --- chardev/char.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/chardev/char.c b/chardev/char.c index e77564060d..c89cae1cd5 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -41,6 +41,10 @@ #include "chardev/char-mux.h" +#ifdef XBOX +extern GMainContext *qemu_main_context; /* FIXME: Cleanup */ +#endif + /***********************************************************/ /* character device */ @@ -203,7 +207,17 @@ void qemu_chr_be_update_read_handlers(Chardev *s, assert(qemu_chr_has_feature(s, QEMU_CHAR_FEATURE_GCONTEXT) || !context); + +#ifdef XBOX + if (context != NULL) { +#endif + s->gcontext = context; + +#ifdef XBOX + } +#endif + if (cc->chr_update_read_handler) { cc->chr_update_read_handler(s); } @@ -249,6 +263,12 @@ static void char_init(Object *obj) Chardev *chr = CHARDEV(obj); chr->logfd = -1; + +#ifdef XBOX + /* Explicitly default to qemu_main_context, not the global context via NULL. */ + chr->gcontext = qemu_main_context; +#endif + qemu_mutex_init(&chr->chr_write_lock); /* @@ -971,8 +991,17 @@ static Chardev *chardev_new(const char *id, const char *typename, obj = object_new(typename); chr = CHARDEV(obj); chr->label = g_strdup(id); + +#ifdef XBOX + if (gcontext != NULL) { +#endif + chr->gcontext = gcontext; +#ifdef XBOX + } +#endif + qemu_char_open(chr, backend, &be_opened, &local_err); if (local_err) { goto end;