Il 17/12/2012 18:08, Michael S. Tsirkin ha scritto:
>>> I would still prefer this logic to reside in virtio.c instead of being
>>> duplicated in each bus.
>>> My idea was to simply call qdev_reset_all on the binding from virtio.c
>>> but other ideas wellcome.
>>
>> I think you're confusing "in the common superclass of all virtio
>> transports" vs "in the common superclass of all virtio devices".
>> virtio.c only implements a common superclass of all virtio devices; in
>> fact, there is no common superclass of all virtio transports, and it is
>> not possible without multiple inheritance or stuff like traits (you're
>> already inheriting from PCIDevice for virtio-*-pci).
>>
>> Such common superclass, if it existed, would abstract stuff like "write
>> zero to the status register" and would call qdev_reset_all.  But again,
>> we don't have this concept.
> 
> There's some misunderstanding here.
> 
> This is not about classes and stuff.
> 
> Common code should be in a single place so everyone can reuse it through
> function calls, not duplicated in all transports.
> And yes we do have examples of this if you are asking for examples;
> examples are functions like virtio_reset, virtio_set_status, etc.

We shouldn't need a virtio_reset at all.  It should be invoked
automatically by virtue of having a correct, complete description of
virtio in terms of qdev buses.

In other words, qdev_reset_all _is_ the common code you're seeking.

Paolo

Reply via email to