qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] Re: [PATCH 1/3] virtio infrastructure


From: Dor Laor
Subject: [Qemu-devel] Re: [PATCH 1/3] virtio infrastructure
Date: Wed, 05 Dec 2007 01:44:47 +0200
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)

Anthony Liguori wrote:

Subject: [PATCH 1/3] virtio infrastructure Cc: Rusty Russell <address@hidden> Cc: Avi Kivity <address@hidden> Cc: Dor Laor <address@hidden> 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

reply via email to

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