mirror of https://github.com/xemu-project/xemu.git
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.
This commit is contained in:
parent
4cb8301631
commit
95a3ced4c3
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue