From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Subject: Re: [PATCH 1/6] virtio interace Date: Fri, 21 Sep 2007 14:05:31 +0200 Message-ID: <200709211405.32116.arnd@arndb.de> References: <1190289808.7262.223.camel@localhost.localdomain> <1190290140.7262.228.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Cc: kvm-devel , lguest To: virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Return-path: In-Reply-To: <1190290140.7262.228.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org> Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org On Thursday 20 September 2007, Rusty Russell wrote: > + * virtio_driver - operations for a virtio I/O driver > + * @name: the name of the driver (KBUILD_MODNAME). > + * @owner: the module which contains these routines (ie. THIS_MODULE). > + * @id_table: the ids (we re-use PCI ids) serviced by this driver. > + * @probe: the function to call when a device is found. =A0Returns a tok= en for > + * =A0 =A0remove, or PTR_ERR(). > + * @remove: the function when a device is removed. > + */ > +struct virtio_driver { > +=A0=A0=A0=A0=A0=A0=A0const char *name; > +=A0=A0=A0=A0=A0=A0=A0struct module *owner; > +=A0=A0=A0=A0=A0=A0=A0struct pci_device_id *id_table; > +=A0=A0=A0=A0=A0=A0=A0void *(*probe)(struct device *device, > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0 struct virtio_= config_space *config, > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0 struct virtque= ue_ops *vqops); > +=A0=A0=A0=A0=A0=A0=A0void (*remove)(void *dev); > +}; > + > +int register_virtio_driver(struct virtio_driver *drv); > +void unregister_virtio_driver(struct virtio_driver *drv); > + > +/* The particular virtio backend supplies these. */ > +struct virtio_backend_ops { > + int (*register_driver)(struct virtio_driver *drv); > + void (*unregister_driver)(struct virtio_driver *drv); > +}; > +extern struct virtio_backend_ops virtio_backend_ops; This still seems a little awkward. From what I understand, you register a virtio_driver, which leads to a pci_driver (or whatever you are based on) to be registered behind the covers, so that the pci_device can be used directly as the virtio device. I think there should instead be a pci_driver that automatically binds to all PCI based virtio imlpementations and creates a child device for the actual virtio_device. Then you can have the virtio_driver itself be based on a device_driver, and you can get rid of the global virtio_backend_ops. That will be useful when a virtual machine has two ways to get at the virtio devices, e.g. a KVM guest that has both hcall based probing for virtio devices and some other virtio devices that are exported through PCI. Arnd <>< ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/