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: Paul Brook
Subject: Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups
Date: Mon, 22 Mar 2010 15:51:43 +0000
User-agent: KMail/1.12.4 (Linux/2.6.32-trunk-amd64; KDE/4.3.4; x86_64; ; )

> > 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.

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]