qemu-devel
[Top][All Lists]
Advanced

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

Re: QEMU device refcounting when device creates a container MR


From: Peter Maydell
Subject: Re: QEMU device refcounting when device creates a container MR
Date: Wed, 9 Mar 2022 16:53:27 +0000

On Wed, 9 Mar 2022 at 16:21, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 3/9/22 11:33, Peter Maydell wrote:
> > Hi; does anybody know how device reference counting is supposed
> > to work when the device creates a "container" MemoryRegion which
> > it then puts some of its own subregions in to?
> >
> > As far as I can see when you do memory_region_add_subregion it
> > increases the refcount on the owner of the subregion. So if a
> > device creates a container MR in its own init or realize method
> > and adds sub-MRs that it owns to that container, this increases
> > the refcount on the device permanently, and so the device won't
> > ever be deinited.
>
> The unparent method is supposed to break reference cycles.
>
> In the case of QOM, unparent calls unrealize, so unrealize should remove
> the subregions it created.

It seems asymmetric for unrealize to undo something that was
done in instance_init, though. I would expect unrealize to
undo the effects of realize, and instance_finalize to undo
the effects of instance_init.

-- PMM



reply via email to

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