@samitouri / QOSamiQemu / commits / a97f171c40

ui/console: unregister console from QOM tree on close

Call object_unparent() in graphic_console_close() to remove the console from /backend/console[N]. This drops the QOM tree reference, while the initial object_new() reference keeps the console alive for potential reuse. When graphic_console_init() reuses a closed console, re-register it in the QOM tree. 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-32-4656aec3398d@redhat.com>

Marc-André Lureau committed Jun 23, 2026 at 11:44 UTC a97f171c4033c923182abbe0d72a804643016c8d
1 file changed +4
ui/console.c
+4
@@ -1140,6 +1140,9 @@ QemuConsole *qemu_graphic_console_create(DeviceState *dev, uint32_t head,
1140 trace_console_gfx_reuse(s->index);
1141 width = qemu_console_get_width(s, 0);
1142 height = qemu_console_get_height(s, 0);
1143 + if (s->ds->initialized) {
1144 + qemu_console_add_to_qom(s);
1145 + }
1146 } else {
1147 trace_console_gfx_new();
1148 s = (QemuConsole *)object_new(TYPE_QEMU_GRAPHIC_CONSOLE);
@@ -1180,6 +1183,7 @@ void qemu_graphic_console_close(QemuConsole *con)
1183 }
1184 surface = qemu_create_placeholder_surface(width, height, unplugged);
1185 qemu_console_set_surface(con, surface);
1186 + object_unparent(OBJECT(con));
1187 }
1188
1189 QemuConsole *qemu_console_lookup_default(void)