On Thu, Mar 12, 2026 at 1:36 PM Stefan Hajnoczi <[email protected]> wrote:
>
> On Tue, Mar 10, 2026 at 06:15:16PM +0800, Zhang Chen wrote:
> > On Mon, Mar 9, 2026 at 4:44 PM Stefan Hajnoczi <[email protected]> wrote:
> > >
> > > On Thu, Mar 05, 2026 at 10:24:53PM +0800, Zhang Chen wrote:
> > > > @@ -1434,11 +1436,17 @@ static void colo_compare_finalize(Object *obj)
> > > >
> > > > qemu_bh_delete(s->event_bh);
> > > >
> > > > - AioContext *ctx = iothread_get_aio_context(s->iothread);
> > > > + /*
> > > > + * Use the device's canonical path as the holder ID to track
> > > > IOThread
> > > > + * usage and ensure the AioContext remains valid during the
> > > > device's
> > > > + * lifecycle.
> > > > + */
> > > > + AioContext *ctx = iothread_get_aio_context(s->iothread, NULL);
> > >
> > > Should NULL be path?
> > >
> >
> > Yes, here code in the finalize function need to waiting for the
> > coroutine to complete processing
> > Or do you have any other suggestion?
>
> I'm not sure I understand. My question was about:
>
> AioContext *ctx = iothread_get_aio_context(s->iothread, NULL);
> ^^^^
>
> NULL is passed as the argument but this function has a 'path' local
> variable. The path variable should be passed instead of NULL.
Let me explain in detail.
colo-compare have two real holders for the iothread,
1. colo_compare_timer_init.
2. worker_context for chardev handlers.
I try to make them use one pair of iothread_get/put.
The real iothread_get with "path" is here:
static void colo_compare_iothread(CompareState *s)
{
- AioContext *ctx = iothread_get_aio_context(s->iothread);
- object_ref(OBJECT(s->iothread));
+ char *path = object_get_canonical_path(OBJECT(s));
+ AioContext *ctx = iothread_get_aio_context(s->iothread, path);
+
The real pairing iothread_put with the "path" is here:
AIO_WAIT_WHILE(ctx, !s->out_sendco.done);
if (s->notify_dev) {
AIO_WAIT_WHILE(ctx, !s->notify_sendco.done);
}
+ iothread_put_aio_context(s->iothread, path);
/* Release all unhandled packets after compare thead exited */
g_queue_foreach(&s->conn_list, colo_flush_packets, s);
Thanks
Chen
>
> Stefan