On 04/12/2012 12:02 PM, Paolo Bonzini wrote:
Il 12/04/2012 18:52, Andreas Färber ha scritto:
Selecting the type of an object should be done by having a link<>
property and letting the user create an object and setup the link.
No, that's not what a link does. A link<> property lets the user
associate one instance, not a type that can be used for multiple
instances. We'd need a template<> or clone<> mechanism for that!
For example, the user specifies -cpu cortex-a9,+neon,-fpu and we have a
dual-core exynos4210 SoC.
I originally had a patch on my qom-cpu-sh4 v1 series where exactly such
a link got criticized by Peter:
http://patchwork.ozlabs.org/patch/146669/
And I agree, it was an ugly workaround around the missing two-stage
constructor support. Therefore I had posted my object_realize() series!
I think this is difficult to reconcile for now. I can see Anthony's
point, which makes a lot of sense from the PC point of view, but then
"magic" configuration can also be important when working with SoC boards.
I don't see such "magic" configurations. Either a SoC has a chip that's
soldered to the board and cannot be changed (it's a child<>) or the SoC has a
socket and you can add in a different component (it's a link<>).
Where does the "magic" come in?
I've added a missing_property hook to my series that can be used to this
end. Accessing a property can trigger creation of the device with the
appropriate class before realization.
I think we need to stick close to something that looks like it could be a real
piece of hardware. Once you add too much magic, it's too easy to do things the
wrong way.
Regards,
Anthony Liguori
Paolo