diff options
| author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2026-06-23 11:44:40 +0400 |
|---|---|---|
| committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2026-06-24 15:41:15 +0400 |
| commit | b05c6e2532059711e8e4f305b291ad4d9c1168f4 (patch) | |
| tree | d244215782031e1b522cdc1643490388053f89a1 /ui | |
| parent | 23ffb0abfadaf87744da091be4cf2abad9ce07e6 (diff) | |
| download | qemu-b05c6e2532059711e8e4f305b291ad4d9c1168f4.tar.gz qemu-b05c6e2532059711e8e4f305b291ad4d9c1168f4.zip | |
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>
Diffstat (limited to 'ui')
| -rw-r--r-- | ui/console-vc.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ui/console-vc.c b/ui/console-vc.c index 828e78c41e..53d9e9d39b 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -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, }; |
