On 6/23/26 12:07, Daniel P. Berrangé wrote:
On Wed, Jun 17, 2026 at 02:49:57PM +0200, Paolo Bonzini wrote:
For buses, the fact that the parent and child live at the same time is
explicitly tracked with mutual refcount and unparent.

If we get mutual ref counting correct, then there is not benefit
to having 2 different ways of allocating QOM objects. We should
eliminate the embedding as pointless extra complexity and focus
on getting ref counting done correctly.

Nobody really *should* notice that there are 2 different ways of allocating QOM objects, just like you don't think about the difference between:

   char *s = "hello";
   g_autofree char *t = g_strdup("world")

The problem is that the mutual ref counting is wrong. Fix that and you won't care about init vs. new.

                                                      If it's not, we have
the hack that Akihiko mentioned
(https://lists.gnu.org/archive/html/qemu-devel/2026-06/msg03459.html):

That hack is too gross.

I agree and it's also wrong.

The relationship between objects does not need to be expressed with
embedding one inside another struct. This should be represented at
the class level with properties for the child relationships, which
would give us introspection via QMP too.  The embedding isn't adding
any real value IMHO.

There is a difference in what the code expresses: you have on one hand an embedded Foo, which has to be tied to the lifetime of the parent, and on the other hand a Foo* which can be anywhere and might be provided by an object property. One is a child<Foo>, the other is a link<Foo>.

Paolo


Reply via email to