qemu-devel
[Top][All Lists]
Advanced

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

Re: QOM address space handling


From: Paolo Bonzini
Subject: Re: QOM address space handling
Date: Sun, 20 Dec 2020 10:25:25 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0

On 18/12/20 23:32, Eduardo Habkost wrote:
Who owns the FlatView reference, exactly?

The AddressSpace. The device creates the AddressSpace, which holds a reference to the MemoryRegion through FlatView and AddressSpaceDispatch, which holds a reference to the device.

By destroying the address space that it created, the device can break the reference loop.

If the FlatView reference is owned by the MemoryRegion, we have a
reference loop: the device holds a reference to the MemoryRegion,
which owns the FlatView, which holds a reference to the device.
In this case, who owns the reference loop and is responsible for
breaking it?

The reference loop is owned by the device, which breaks it through unrealize (called by unparent).

instance_finalize by definition cannot break reference loops, so this means that my suggestion of using address_space_init in instance_init was wrong.

Thanks,

Paolo

If the FlatView reference is not owned by the MemoryRegion, who
owns it?


There are 2 possible solutions here: 1) ensure QOM objects that add
address spaces during instance init have a corresponding instance
finalize function to remove them or 2) move the creation of address
spaces from instance init to realize.

Does anyone have any arguments for which solution is preferred?

I slightly prefer (1) because there could be cases where you also create
subdevices using that address space, and in order to set properties of
subdevices before realize, you would have to create the subdevices in
instance_init as well.




reply via email to

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