On Thu, Jul 16, 2026 at 8:46 PM Stefan Hajnoczi <[email protected]> wrote:
>
> On Mon, Jul 06, 2026 at 04:59:30PM +0800, Zhang Chen wrote:
> > On Thu, Jul 2, 2026 at 2:39 PM Stefan Hajnoczi <[email protected]> wrote:
> > >
> > > On Wed, Jun 24, 2026 at 03:08:42PM +0800, Zhang Chen wrote:
> > > > Since previous patches introduced explicit monitor tracking and 
> > > > reference
> > > > counting via IOThreadHolder during initialization, standard global calls
> > > > to iothread_get_aio_context() are no longer appropriate for raw context
> > > > fetches.
> > > >
> > > > Switch the remaining fallback sites in monitor_suspend(), 
> > > > monitor_resume(),
> > > > and monitor_init_qmp() to use iothread_unsafe_get_aio_context(). This 
> > > > aligns
> > > > with the new safe ref/unref lifecycles introduced for monitor tracking.
> > >
> > > Why is the unsafe API used here? monitor_data_init() now takes a
> > > reference and gets the AioContext. Can you use that AioContext here
> > > instead of fetching it with iothread_unsafe_get_aio_context()?
> >
> > Because we have some comments from this series V8 patches:
> > https://lists.gnu.org/archive/html/qemu-devel/2026-06/msg00375.html
> >
> > If OK, I will back to the V8 code and follow the [PATCH V9 06/17] comments,
> > https://lists.gnu.org/archive/html/qemu-devel/2026-06/msg07323.html
> > based on Daniel's series for monitor parts in V10.
>
> Markus had no objection to using safe ref/unref APIs. I think he didn't
> like the additional AioContext pointer that the caller needed to manage.
>
> Using the safe APIs is important because the risk of bugs is high with
> an unsafe API. If the new safe API is too inconvenient to use, then
> let's find a different API design.
>
> Here is a variation of the API that requires the caller to hold just 1
> thing - the ref:
>
> IOThreadRef *iothread_ref_get(IOThread *iothread, const IOThreadHolder 
> *holder);
> void iothread_ref_put(IOThreadRef *ref);
> AioContext *iothread_ref_get_aio_context(IOThreadRef *ref);
>
> The caller can call iothread_ref_get_aio_aio_context() multiple times,
> so they no longer need to store the AioContext pointer.
>
> Since iothread_ref_put() takes IOThreadRef, the caller doesn't need to
> build a new IOThreadHolder when releasing the reference.
>
> What do you think?
>

The monitor parts based on Daniel P. Berrangé's series:
    [PATCH v7 00/35] monitor: turn QMP and HMP into QOM objects
    
https://lore.kernel.org/qemu-devel/[email protected]/

This part has undergone significant changes; please refer to V10 for
the latest implementation.
https://lists.gnu.org/archive/html/qemu-devel/2026-07/msg04823.html

Thanks
Chen


> Stefan

Reply via email to