From: Dor Laor <dor.laor@gmail.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 1/3] virtio infrastructure
Date: Wed, 05 Dec 2007 01:44:47 +0200 [thread overview]
Message-ID: <4755E66F.3080300@qumranet.com> (raw)
In-Reply-To: <4755CC65.7040908@us.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 3286 bytes --]
Anthony Liguori wrote:
------------------------------------------------------------------------
Subject: [PATCH 1/3] virtio infrastructure
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Avi Kivity <avi@qumranet.com>
Cc: Dor Laor <dor.laor@qumranet.com>
This patch implements the basic infrastructure for virtio devices. These
devices are exposed to the guest as real PCI devices. The PCI vendor/device
IDs have been donated by Qumranet and the subsystem IDs are used to distinguish
the virtio device itself.
Virtio provides an abstraction for performing guest=>host and host=>guest
communications. It also provides a standard ring queue interface and discovery
mechanism. Finally, virtio provides a simple mechanism for passing
configuration between host and guest.
In this virtio implementation, we provide these things via normal PCI
operations. The Linux kernel support for this virtio device is pending in
Rusty's virtio patch queue[1]. They should be submitted once the merge window
opens again.
Some future TODOs are to use endian/alignment safe routines when accessing the
virtqueue so that mixed mode host/guests are supported.
[1] http://ozlabs.org/~rusty/kernel/hg
Index: qemu/Makefile.target
===================================================================
--- qemu.orig/Makefile.target 2007-12-04 10:00:43.000000000 -0600
+++ qemu/Makefile.target 2007-12-04 14:15:20.000000000 -0600
@@ -435,6 +435,9 @@
VL_OBJS += pcnet.o
VL_OBJS += rtl8139.o
+# virtio devices
+VL_OBJS += virtio.o
+
ifeq ($(TARGET_BASE_ARCH), i386)
# Hardware support
VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o
Index: qemu/hw/virtio.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ qemu/hw/virtio.c 2007-12-04 14:17:15.000000000 -0600
@@ -0,0 +1,422 @@
[snip]
+#define VIRTIO_PCI_CONFIG 20
+
[snip]
+static void virtio_map(PCIDevice *pci_dev, int region_num,
+ uint32_t addr, uint32_t size, int type)
+{
+ VirtIODevice *vdev = to_virtio_device(pci_dev);
+ int i;
+
+ vdev->addr = addr;
+ for (i = 0; i < 3; i++) {
+ register_ioport_write(addr, 20, 1 << i, virtio_ioport_write, vdev);
+ register_ioport_read(addr, 20, 1 << i, virtio_ioport_read, vdev);
Can you use VIRTIO_PCI_CONFIG instead of 20?
+ }
+
+ if (vdev->config_len) {
+ register_ioport_write(addr + 20, vdev->config_len, 1,
+ virtio_config_writeb, vdev);
+ register_ioport_write(addr + 20, vdev->config_len, 2,
+ virtio_config_writew, vdev);
+ register_ioport_write(addr + 20, vdev->config_len, 4,
+ virtio_config_writel, vdev);
+ register_ioport_read(addr + 20, vdev->config_len, 1,
+ virtio_config_readb, vdev);
+ register_ioport_read(addr + 20, vdev->config_len, 2,
+ virtio_config_readw, vdev);
+ register_ioport_read(addr + 20, vdev->config_len, 4,
+ virtio_config_readl, vdev);
+
+ vdev->update_config(vdev, vdev->config);
+ }
+}
+
+
I liked the push/pop functions, this encapsulation improves code
readability, cheers.
Dor.
+void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem,
+ unsigned int len);
+
+int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem);
+
+void virtio_notify(VirtIODevice *vdev, VirtQueue *vq);
+
+#endif
[-- Attachment #2: Type: text/html, Size: 3979 bytes --]
prev parent reply other threads:[~2007-12-04 23:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-04 21:53 [Qemu-devel] [PATCH 1/3] virtio infrastructure Anthony Liguori
2007-12-04 23:44 ` Dor Laor [this message]
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=4755E66F.3080300@qumranet.com \
--to=dor.laor@gmail.com \
--cc=aliguori@us.ibm.com \
--cc=dor.laor@qumranet.com \
--cc=qemu-devel@nongnu.org \
--cc=rusty@rustcorp.com.au \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.