qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups


From: Michael S. Tsirkin
Subject: Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups
Date: Mon, 22 Mar 2010 19:19:46 +0200
User-agent: Mutt/1.5.19 (2009-01-05)

On Mon, Mar 22, 2010 at 03:51:43PM +0000, Paul Brook wrote:
> > > It's a classic OOP problem.
> > >
> > > VirtIOBlock is-a VirtIODevice, VirtIODevice is-a DeviceState
> > >
> > > VirtIOPCI is-a PCIDevice, PCIDevice is-a Device State.
> > >
> > > But VirtIODevice is-a VirtIOPCI device isn't always true so it can't be
> > > an is-a relationship.  Initially, this was true and that's why the code
> > > was structured that way.  Now that we have two type so of virtio
> > > transports, we need to change the modelling.  It needs to get inverted
> > > into a has-a relationship.  IOW, VirtIOPCI has-a VirtIODevice.
> > >
> > > When one device has-a one or more other devices, we model that as a Bus.
> > 
> > Hmm. Is anything wrong with VirtIOPCIBlock which would be both a
> >  VirtIOBlock and VirtIOPCI device?
> 
> You need to solve multiple inheritance with common (but divergent) ancestors.
> 
> A single device may not have more than one DeviceState. i.e. the DeviceState 
> that is part of the VirtIOBlock must be the same as the DeviceState that is 
> part of the PCIDevice. However VirtIOBlock and PCIDevice can not know about 
> each other or about VirtIOPCIBlock.
> 
> In the current code VirtIOPCIBlock already exists, though only for the 
> purposes of device creation/configuration. The remainder of the code and data 
> structures have clean separation between PCI and Virtio code.

We can have VirtIOPCIBlock have a single DeviceState.

> Anthony's suggestion is that we turn VirtIODevice into a user visible entity 
> (rather than an implementation detail). This makes the hoist bindings (virtio-
> pci.c) completely independent of the virtio backends (e.g. virtio-block.c). 
> VirtIOPCIBlock ceases to exist, except maybe as a helpful alias to create a 
> VirtioPCI[Proxy]/VirtioBlock pair.
>  
> > > It's just like SCSI.  SCSIDisk is-a SCSIDevice, SCSIDevice is-a
> > > DeviceState.
> > >
> > > LSIState is-a PCIDevice, PCIDevice is-a DeviceState.
> > >
> > > LSIState has-a SCSIDevice because LSIState implements the SCSIBus
> > > interface.
> > 
> > Yes but LSIState emulates a real HBI ...
> 
> Not relevant.  There should be nothing magic about virtio.  If there is then 
> we're doing it wrong.
>  
> Paul




reply via email to

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