From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: Stephen Rothwell <sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org>,
Xen Mailing List
<xen-devel-GuqFBffKawuULHF6PoxzQEEOCMrvLtNR@public.gmane.org>,
"jmk-zzFmDc4TPjtKvsKVC3L/VUEOCMrvLtNR@public.gmane.org"
<jmk-zzFmDc4TPjtKvsKVC3L/VUEOCMrvLtNR@public.gmane.org>,
Christian Borntraeger
<cborntra-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>,
virtualization
<virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
Latchesar Ionkov <lionkov-YOWKrPYUwWM@public.gmane.org>,
Suzanne McIntosh
<skranjac-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>,
Martin Schwidefsky
<schwidefsky-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH] Lguest implemention of virtio draft III
Date: Sat, 16 Jun 2007 15:50:52 +0200 [thread overview]
Message-ID: <200706161550.53043.arnd@arndb.de> (raw)
In-Reply-To: <1182000514.6237.273.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
On Saturday 16 June 2007, Rusty Russell wrote:
> This is a bonus patch for those wondering how a virtio implementation
> can look.
Thanks, I assumed it was something like this, but having the code
in front of me makes it a lot easier to comment on it.
> +static struct lguest_driver lguest_virtnet_drv = {
> + .name = "lguestvirtnet",
> + .owner = THIS_MODULE,
> + .device_type = LGUEST_DEVICE_T_VIRTNET,
> + .probe = lguest_virtnet_probe,
> +};
> +
> +static __init int lguest_virtnet_init(void)
> +{
> + return register_lguest_driver(&lguest_virtnet_drv);
> +}
> +device_initcall(lguest_virtnet_init);
> +
> +/* Example block driver code. */
> +#include <linux/virtio_blk.h>
> +#include <linux/genhd.h>
> +#include <linux/blkdev.h>
> +static int lguest_virtblk_probe(struct lguest_device *lgdev)
> +{
> + struct lguest_virtio_device *lgv;
> + struct gendisk *disk;
> + unsigned long sectors;
> + int err;
> +
> + lgv = lg_new_virtio(lgdev);
> + if (!lgv)
> + return -ENOMEM;
> +
> + /* Page is initially used to pass capacity. */
> + sectors = *(unsigned long *)lgv->in.desc;
> + *(unsigned long *)lgv->in.desc = 0;
> +
> + lgv->priv = disk = virtblk_probe(&lgv->vdev);
> + if (IS_ERR(lgv->priv)) {
> + err = PTR_ERR(lgv->priv);
> + goto destroy;
> + }
> + set_capacity(disk, sectors);
> + blk_queue_max_hw_segments(disk->queue, NUM_DESCS-1);
> +
> + err = lg_setup_interrupt(lgv, disk->disk_name);
> + if (err)
> + goto unprobe;
> + add_disk(disk);
> + return 0;
> +
> +unprobe:
> + virtblk_remove(disk);
> +destroy:
> + lg_destroy_virtio(lgv);
> + return err;
> +}
> +
> +static struct lguest_driver lguest_virtblk_drv = {
> + .name = "lguestvirtblk",
> + .owner = THIS_MODULE,
> + .device_type = LGUEST_DEVICE_T_VIRTBLK,
> + .probe = lguest_virtblk_probe,
> +};
> +
> +static __init int lguest_virtblk_init(void)
> +{
> + return register_lguest_driver(&lguest_virtblk_drv);
> +}
> +device_initcall(lguest_virtblk_init);
This is the part that I find puzzling. My idea would be that the drivers
and devices you register are _not_ specific to the type of virtio bus.
The problem I see with your approach is that drivers for specific devices
can't be loaded as separate modules, right now all of them have to be
loaded or statically linked into the kernel in order to load the
lguest_virtio module.
I'm sure you know how this works for other buses, but I'll explain anyway
so that everyone knows what I'm talking about. What I have in mind is
to have a single 'struct bus_type virtio_bus_type', which is used by
all virtio implementations. The 'struct virtio_device' is derived from
'struct device', meaning that a 'struct device' is embedded in it.
Each virtio implementation can either use the virtio_device directly,
or derive its own kvm_virtio_device/lguest_virtio_device/... from it.
When lguest scans its devices, it registers the lguest_virtio_device
with the generic virtio_bus_type, not an lguest specific one.
Similarly, the block/net/... drivers each register themselves as
a virtio_driver with the virtio_bus_type, not with an implementation
specific guest.
Do you see a problem with the approach that I described here, or did
you just not bother implementing it so far?
Arnd <><
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
next prev parent reply other threads:[~2007-06-16 13:50 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-07 12:02 [PATCH RFC 0/3] Virtio draft II Rusty Russell
2007-06-07 12:04 ` [PATCH RFC 1/3] Virtio draft II: virtio.h Rusty Russell
[not found] ` <1181217867.14054.195.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-07 12:05 ` [PATCH RFC 2/3] Virtio draft II: example block driver Rusty Russell
[not found] ` <1181217920.14054.196.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-07 12:07 ` [PATCH RFC 3/3] Virtio draft II: example net driver Rusty Russell
2007-06-07 12:19 ` [PATCH RFC 2/3] Virtio draft II: example block driver Avi Kivity
[not found] ` <4667F7C0.3070604-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-08 1:11 ` Rusty Russell
[not found] ` <1181217762.14054.192.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-16 13:12 ` [PATCH RFC 0/3] Virtio draft III Rusty Russell
[not found] ` <1181999552.6237.255.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-16 13:14 ` [PATCH RFC 1/3] Virtio draft III: virtio.h Rusty Russell
[not found] ` <1181999669.6237.257.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-16 13:17 ` [PATCH RFC 2/3] Virtio draft III: example net driver Rusty Russell
[not found] ` <1181999825.6237.260.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-16 13:18 ` [PATCH RFC 3/3] Virtio draft III: example block driver Rusty Russell
[not found] ` <1181999920.6237.263.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-16 13:28 ` [PATCH] Lguest implemention of virtio draft III Rusty Russell
[not found] ` <1182000514.6237.273.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-16 13:50 ` Arnd Bergmann [this message]
2007-06-17 14:25 ` [PATCH RFC 3/3] Virtio draft III: example block driver Avi Kivity
[not found] ` <46754451.2010305-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-18 8:08 ` Rusty Russell
[not found] ` <1182154095.19064.24.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-18 9:09 ` Avi Kivity
[not found] ` <46764BB5.6070704-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-19 6:27 ` Rusty Russell
[not found] ` <1182234466.19064.51.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-19 8:34 ` Avi Kivity
2007-06-25 15:26 ` [PATCH RFC 2/3] Virtio draft III: example net driver Brian King
[not found] ` <467FDEAD.4030204-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2007-06-25 19:33 ` Christoph Hellwig
[not found] ` <20070625193304.GB25736-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2007-06-25 21:54 ` Avi Kivity
[not found] ` <46803999.4040500-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-25 22:13 ` Brian King
[not found] ` <46803E0E.7080103-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2007-06-25 22:20 ` Avi Kivity
2007-06-28 11:20 ` Rusty Russell
[not found] ` <1183029641.12401.36.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-28 15:55 ` Brian King
2007-06-17 14:14 ` [PATCH RFC 0/3] Virtio draft III Avi Kivity
[not found] ` <467541DF.5060907-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-18 7:48 ` [Xen-devel] " Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200706161550.53043.arnd@arndb.de \
--to=arnd-r2ngtmty4d4@public.gmane.org \
--cc=cborntra-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org \
--cc=jmk-zzFmDc4TPjtKvsKVC3L/VUEOCMrvLtNR@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=lionkov-YOWKrPYUwWM@public.gmane.org \
--cc=schwidefsky-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org \
--cc=sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org \
--cc=skranjac-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
--cc=virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=xen-devel-GuqFBffKawuULHF6PoxzQEEOCMrvLtNR@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox