mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
ui/console: register console in QOM tree dynamically
Consoles created after init_displaystate() (e.g. hotplugged display devices) were never added to the /backend/console[N] QOM tree. Extract qemu_console_add_to_qom() and call it from qemu_console_register() when the display is already initialized. Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260623-b4-ui-v4-31-4656aec3398d@redhat.com>
This commit is contained in:
23
ui/console.c
23
ui/console.c
@@ -68,6 +68,7 @@ struct DisplayState {
|
||||
uint64_t last_update;
|
||||
uint64_t update_interval;
|
||||
bool refreshing;
|
||||
bool initialized;
|
||||
|
||||
QLIST_HEAD(, DisplayChangeListener) listeners;
|
||||
NotifierList console_notifiers;
|
||||
@@ -376,6 +377,13 @@ void qemu_text_console_put_string(QemuTextConsole *s, const char *str, int len)
|
||||
}
|
||||
}
|
||||
|
||||
static void qemu_console_add_to_qom(QemuConsole *con)
|
||||
{
|
||||
g_autofree gchar *name = g_strdup_printf("console[%d]", con->index);
|
||||
object_property_add_child(object_get_container("backend"),
|
||||
name, OBJECT(con));
|
||||
}
|
||||
|
||||
static void
|
||||
qemu_console_register(QemuConsole *c)
|
||||
{
|
||||
@@ -413,6 +421,10 @@ qemu_console_register(QemuConsole *c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (c->ds->initialized) {
|
||||
qemu_console_add_to_qom(c);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1089,20 +1101,19 @@ void qemu_console_remove_notifier(Notifier *notifier)
|
||||
*/
|
||||
DisplayState *init_displaystate(void)
|
||||
{
|
||||
gchar *name;
|
||||
DisplayState *ds = get_alloc_displaystate();
|
||||
QemuConsole *con;
|
||||
|
||||
QTAILQ_FOREACH(con, &consoles, next) {
|
||||
/* Hook up into the qom tree here (not in object_new()), once
|
||||
* all QemuConsoles are created and the order / numbering
|
||||
* doesn't change any more */
|
||||
name = g_strdup_printf("console[%d]", con->index);
|
||||
object_property_add_child(object_get_container("backend"),
|
||||
name, OBJECT(con));
|
||||
g_free(name);
|
||||
qemu_console_add_to_qom(con);
|
||||
}
|
||||
|
||||
return display_state;
|
||||
ds->initialized = true;
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
||||
void qemu_graphic_console_set_hwops(QemuConsole *con,
|
||||
|
||||
Reference in New Issue
Block a user