mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:17 +00:00
ui/console-vc: fire ADDED/REMOVED notifications
Fire CONSOLE_ADDED when the chardev is opened. Fire CONSOLE_REMOVED in char_vc_finalize() before dropping the console reference, so the console is still in a valid state when listeners handle the event. Also fixes a console object leak by adding the missing object_unref(). 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-25-4656aec3398d@redhat.com>
This commit is contained in:
@@ -255,6 +255,7 @@ static bool vc_chr_open(Chardev *chr, ChardevBackend *backend, Error **errp)
|
||||
}
|
||||
|
||||
qemu_chr_be_event(chr, CHR_EVENT_OPENED);
|
||||
qemu_console_notify(QEMU_CONSOLE_ADDED, QEMU_CONSOLE(s));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -327,12 +328,24 @@ static void char_vc_init(Object *obj)
|
||||
vc->encoding = CHARDEV_VC_ENCODING_UTF8;
|
||||
}
|
||||
|
||||
static void char_vc_finalize(Object *obj)
|
||||
{
|
||||
VCChardev *vc = VC_CHARDEV(obj);
|
||||
QemuConsole *con = QEMU_CONSOLE(vc->console);
|
||||
|
||||
if (con) {
|
||||
qemu_console_notify(QEMU_CONSOLE_REMOVED, con);
|
||||
object_unref(con);
|
||||
}
|
||||
}
|
||||
|
||||
static const TypeInfo char_vc_type_info = {
|
||||
.name = TYPE_CHARDEV_VC,
|
||||
.parent = TYPE_CHARDEV,
|
||||
.instance_size = sizeof(VCChardev),
|
||||
.instance_init = char_vc_init,
|
||||
.instance_post_init = object_apply_compat_props,
|
||||
.instance_finalize = char_vc_finalize,
|
||||
.class_init = char_vc_class_init,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user