Paolo Bonzini <pbonz...@redhat.com> writes: > On 28/07/20 09:19, Markus Armbruster wrote: >>> the composition tree generally mirrors things that are born and die >>> at the same time, and creating children is generally reserved to the >>> object itself. >> >> Yes. Notable exceptions: containers /machine/peripheral, >> /machine/peripheral-anon, /machine/unattached. > > And /objects too. Apart from /machine/unattached, all these dynamic > objects are created by the monitor or the command line. > >>> Children are usually embedded directly in a struct, for >>> example. >> >> We sometimes use object_new() + object_property_add_child() instead. >> Extra indirection. I guess we'd be better off without the extra >> indirection most of the time. Implementation detail. >> >> We sometimes use object_new() without object_property_add_child(), and >> have qdev_realize() put the device in the /machine/unattached orphanage. >> Meh. I guess the orphanage feature exists to make conversion to QOM >> slightly easier. Could we ban its use for new boards at least? > > Banning perhaps is too strong, but yes /machine/unattached is an > anti-pattern.
A ban backed by an automated test will be effective. Writing "but don't do that" on the list not so much. The automated test could have a list of exceptions. Adding a new instance of the anti-pattern then isn't impossible (you can update the list of exceptions), but clearly visible to patch submitter and reviewers. [...]