qemu-devel
[Top][All Lists]
Advanced

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

Re: qom device lifecycle interaction with hotplug/hotunplug ?


From: Eduardo Habkost
Subject: Re: qom device lifecycle interaction with hotplug/hotunplug ?
Date: Fri, 29 Nov 2019 16:53:43 -0300

On Fri, Nov 29, 2019 at 01:40:55PM +0100, Igor Mammedov wrote:
> On Thu, 28 Nov 2019 13:33:58 -0300
> Eduardo Habkost <address@hidden> wrote:
> 
> > On Thu, Nov 28, 2019 at 04:00:06PM +0000, Peter Maydell wrote:
> > > Hi; this is a question which came up in Damien's reset series
> > > which I don't know the answer to:
> > > 
> > > What is the interaction of the QOM device lifecycle 
> > > (instance_init/realize/
> > > unrealize/instance_finalize) with hotplug and hot-unplug ? I couldn't
> > > find any documentation of this but maybe I was looking in the wrong
> > > place...
> > > 
> > > Looking at device_set_realized() it seems like we treat "realize"
> > > as meaning "and also do the hot-plug if this is a device we're
> > > trying to hotplug". On the other hand hot-unplug is I think the
> > > other way around: when we get a hot-unplug event we assume that
> > > it should also imply an "unrealize" (but just unrealizing doesn't
> > > auto-hot-unplug) ?  
> > 
> > Your description seems accurate, and I agree it is confusing.
> > 
> > It would be more consistent if realized=true didn't plug the
> > device automatically, and qdev_device_add() asked the hotplug
> > handler to plug the device instead.
> agreed, it's confusing. But that would not allow to
>   o = object_new()
>   set props
>   o.realize()
> reuse the same plug handlers.
> 

I thought we had very few places that set realized=true directly,
so changing this behavior would be easy.

I was mistaken.  Grepping for 'set_bool.*"realized"' found more
than 300 matches.

> we potentially can convert it to device_add input arguments
> and then call qdev_device_add() instead, which would then
> handle plug handlers, not sure it's doable though.
> Other than that I don't have any ideas how to make it less confusing.

We could introduce a "plugged" property which implicitly calls
the hotplug handler, and run a global s/"realized"/"plugged"/
substitution in the whole tree.  Would it be worth the trouble,
though?

-- 
Eduardo




reply via email to

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