Re: [PATCH v2] Driver for Inter-VM shared memory device for KVM supporting interrupts.

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

 



Am Montag 18 Mai 2009 16:26:15 schrieb Avi Kivity:
> Christian Borntraeger wrote:
> > Sorry for the late question, but I missed your first version. Is there a
> > way to change that code to use virtio instead of PCI? That would allow us
> > to use this driver on s390 and maybe other virtio transports.
>
> Opinion differs.  See the discussion in
> http://article.gmane.org/gmane.comp.emulators.kvm.devel/30119.
>
> To summarize, Anthony thinks it should use virtio, while I believe
> virtio is useful for exporting guest memory, not for importing host memory.

I think the current virtio interface is not ideal for importing host memory, 
but we can change that. If you look at the dcssblk driver for s390, it allows 
a guest to map shared memory segments via a diagnose (hypercall). This driver 
uses PCI regions to map memory.

My point is, that the method to map memory is completely irrelevant, we just 
need something like mmap/shmget between the guest and the host. We could 
define an interface in virtio, that can be used by any transport. In case of 
pci this could be a simple pci map operation. 

What do you think about something like: (CCed Rusty)
---
 include/linux/virtio.h |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Index: linux-2.6/include/linux/virtio.h
===================================================================
--- linux-2.6.orig/include/linux/virtio.h
+++ linux-2.6/include/linux/virtio.h
@@ -71,6 +71,31 @@ struct virtqueue_ops {
 };
 
 /**
+ * virtio_device_ops - operations for virtio devices
+ * @map_region: map host buffer at a given address
+ *	vdev: the struct virtio_device we're talking about.
+ *	addr: The address where the buffer should be mapped (hint only)
+ *	length: THe length of the mapping
+ *	identifier: the token that identifies the host buffer
+ *      Returns the mapping address or an error pointer.
+ * @unmap_region: unmap host buffer from the address
+ *	vdev: the struct virtio_device we're talking about.
+ *	addr: The address where the buffer is mapped
+ *      Returns 0 on success or an error
+ *
+ * TBD, we might need query etc.
+ */
+struct virtio_device_ops {
+	void * (*map_region)(struct virtio_device *vdev,
+			     void *addr,
+			     size_t length,
+			     int identifier);
+	int (*unmap_region)(struct virtio_device *vdev, void *addr);
+/* we might need query region and other stuff */
+};
+
+
+/**
  * virtio_device - representation of a device using virtio
  * @index: unique position on the virtio bus
  * @dev: underlying device.
@@ -85,6 +110,7 @@ struct virtio_device
 	struct device dev;
 	struct virtio_device_id id;
 	struct virtio_config_ops *config;
+	struct virtio_device_ops *ops;
 	/* Note that this is a Linux set_bit-style bitmap. */
 	unsigned long features[1];
 	void *priv;



--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux