Re: [PATCH V12 06/15] monitor: track IOThread users with QOM paths

Zhang Chen <[email protected]>
Newsgroups org.nongnu.qemu-devel
Message-ID <CAK3tnvJYgzO32QYD1p8DhuYDkeeFAn9mpk+RQbikBi=1WAmeNQ@mail.gmail.com>
On Thu, Aug 20, 2026 at 3:12 AM Stefan Hajnoczi <[email protected]> wrote:
>
> 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.

Yes. Since the canonical path is no longer available in monitor_finalize(),
I’ll move the cleanup to the Monitor’s ObjectClass::unparent callback instead.
It runs before the object is detached, avoids storing the path, and removes the
duplication in monitor_cleanup() and monitor_qmp_prepare_delete().

Thanks
Chen
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.