ui/console: fire console ADDED/REMOVED notifications

Fire CONSOLE_ADDED at the end of graphic_console_init() and
CONSOLE_REMOVED at the start of graphic_console_close(), so display
backends can react to console hotplug/unplug events.

REMOVED fires before the device link is cleared and before the
placeholder surface swap, so handlers can unregister their DCL while
the console is still in a known state.

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-24-4656aec3398d@redhat.com>
This commit is contained in:
Marc-André Lureau
2026-06-23 11:44:39 +04:00
parent 6ca4df5e9c
commit 23ffb0abfa

View File

@@ -1142,6 +1142,7 @@ QemuConsole *qemu_graphic_console_create(DeviceState *dev, uint32_t head,
surface = qemu_create_placeholder_surface(width, height, noinit);
qemu_console_set_surface(s, surface);
qemu_console_notify(QEMU_CONSOLE_ADDED, s);
return s;
}
@@ -1158,6 +1159,7 @@ void qemu_graphic_console_close(QemuConsole *con)
int height = qemu_console_get_height(con, 480);
trace_console_gfx_close(con->index);
qemu_console_notify(QEMU_CONSOLE_REMOVED, con);
object_property_set_link(OBJECT(con), "device", NULL, &error_abort);
qemu_graphic_console_set_hwops(con, &unused_ops, NULL);
timer_del(con->ui_timer);