qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC v2 09/22] monitor: create monitor dedicate iothrea


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [RFC v2 09/22] monitor: create monitor dedicate iothread
Date: Wed, 18 Oct 2017 17:32:46 +0200
User-agent: Mutt/1.9.1 (2017-09-22)

On Mon, Oct 16, 2017 at 03:16:17PM +0800, Peter Xu wrote:
> On Thu, Oct 12, 2017 at 01:29:11PM +0100, Stefan Hajnoczi wrote:
> > On Fri, Sep 29, 2017 at 11:38:31AM +0800, Peter Xu wrote:
> > > @@ -4126,10 +4150,23 @@ void monitor_init(Chardev *chr, int flags)
> > >      qemu_mutex_unlock(&monitor_lock);
> > >  }
> > >  
> > > +static void monitor_io_thread_destroy(void)
> > > +{
> > > +    iothread_destroy(mon_global.mon_io_thread);
> > > +    mon_global.mon_io_thread = NULL;
> > > +}
> > > +
> > >  void monitor_cleanup(void)
> > >  {
> > >      Monitor *mon, *next;
> > >  
> > > +    /*
> > > +     * We need to explicitly stop the iothread (but not destroy it),
> > > +     * cleanup the monitor resources, then destroy the iothread.  See
> > > +     * again on the glib bug mentioned in 2b316774f6 for a reason.
> > > +     */
> > > +    iothread_stop(mon_global.mon_io_thread);
> > > +
> > >      qemu_mutex_lock(&monitor_lock);
> > >      QLIST_FOREACH_SAFE(mon, &mon_list, entry, next) {
> > >          QLIST_REMOVE(mon, entry);
> > > @@ -4137,6 +4174,8 @@ void monitor_cleanup(void)
> > >          g_free(mon);
> > >      }
> > >      qemu_mutex_unlock(&monitor_lock);
> > > +
> > > +    monitor_io_thread_destroy();
> > >  }
> > 
> > Minor style comment, I would inline monitor_io_thread_destroy() into
> > monitor_cleanup() instead of making it a function.
> > 
> > monitor_io_thread_destroy() relies on iothread_stop() being called
> > first.  Defining a function with no doc comment creates a risk that
> > someone else will call it in the future without first calling
> > iothread_stop().  It's safer to inline the code where it cannot be
> > misused by accident.
> 
> There will be some more lines added to monitor_io_thread_destroy() in
> follow-up patches.  I was trying to put iothread things all into this
> function but I cannot really do that since the glib bug (then we'll
> need explicit iothread_stop() above). But sure, I can inline them all.

Or add a doc comment to monitor_io_thread_destroy() so callers know
about the assumption.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]