On Sat, Aug 15, 2026 at 01:48:20AM +0800, Zhang Chen wrote:
> @@ -668,6 +668,17 @@ void monitor_cleanup(void)
>          qemu_mutex_unlock(&monitor_lock);
>          monitor_flush(mon);
>          qemu_mutex_lock(&monitor_lock);
> +
> +        if (monitor_requires_iothread(mon)) {
> +            g_autofree char *path = object_get_canonical_path(OBJECT(mon));
> +            const IOThreadHolder io_holder = {
> +                .type = IO_THREAD_HOLDER_KIND_QOM_OBJECT,
> +                .u.qom_object.qom_path = path,
> +            };
> +
> +            iothread_unref_and_put_aio_context(mon_iothread, &io_holder);
> +            mon->ctx = NULL;
> +        }

Is it possible to move this to monitor_finalize() so it's guaranteed to
run when a Monitor object is deleted with object_unparent()? That would
avoid the code duplication in monitor_qmp_prepare_delete().

One complication is that object_get_canonical_path() may not work inside
monitor_finalize(), so it may be necessary to store the IOThreadHolder
or at least the qom_path in Monitor.

Attachment: signature.asc
Description: PGP signature

Reply via email to