Hi On Thu, Jun 11, 2026 at 11:51 AM Akihiko Odaki <[email protected]> wrote: > > On 2026/06/08 16:16, Marc-André Lureau wrote: > > 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. > > > > Signed-off-by: Marc-André Lureau <[email protected]> > > --- > > ui/console.c | 17 ++++++++++++----- > > 1 file changed, 12 insertions(+), 5 deletions(-) > > > > diff --git a/ui/console.c b/ui/console.c > > index 975eaf15706..e01d893df4b 100644 > > --- a/ui/console.c > > +++ b/ui/console.c > > @@ -376,6 +376,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 +420,10 @@ qemu_console_register(QemuConsole *c) > > } > > } > > } > > + > > + if (phase_check(PHASE_MACHINE_READY)) { > > + qemu_console_add_to_qom(c); > > + } > > Coldplugged consoles are not added to the QOM tree when -preconfig is > specified because x-exit-preconfig will happen after init_displaystate() > but before phase_advance(PHASE_MACHINE_READY). Below is an LLM-written > reproduction case: > > build/qemu-system-x86_64 \ > -machine q35 -nodefaults -display none -S -preconfig \ > -device bochs-display,id=gfx0 -qmp stdio <<'EOF' > {"execute":"qmp_capabilities"} > {"execute":"qom-list","arguments":{"path":"/backend"}} > {"execute":"x-exit-preconfig"} > {"execute":"qom-list","arguments":{"path":"/backend"}} > {"execute":"qom-list","arguments":{"path":"/machine/peripheral"}} > {"execute":"qom-list","arguments":{"path":"/backend/console[0]"}} > {"execute":"quit"} > EOF
good catch, I will have to introduce a state for when display is initialized.
