All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: "Christian Bornträger" <borntraeger@de.ibm.com>
Cc: Avi Kivity <avi@redhat.com>, Cam Macdonell <cam@cs.ualberta.ca>,
	kvm@vger.kernel.org, Rusty Russell <rusty@rustcorp.com.au>,
	Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Subject: Re: [PATCH v2] Driver for Inter-VM shared memory device for KVM supporting interrupts.
Date: Tue, 19 May 2009 13:39:24 -0500	[thread overview]
Message-ID: <4A12FCDC.5040008@codemonkey.ws> (raw)
In-Reply-To: <200905191100.14252.borntraeger@de.ibm.com>

Christian Bornträger wrote:
> 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 */
> +};
>   

Perhaps something that maps closer to the current add_buf/get_buf API.  
Something like:

struct iovec *(*map_buf)(struct virtqueue *vq, unsigned int *out_num, 
unsigned int *in_num);
void (*unmap_buf)(struct virtqueue *vq, struct iovec *iov, unsigned int 
out_num, unsigned int in_num);

There's symmetry here which is good.  The one bad thing about it is 
forces certain memory to be read-only and other memory to be 
read-write.  I don't see that as a bad thing though.

I think we'll need an interface like this so support driver domains too 
since "backend".  To put it another way, in QEMU, map_buf == 
virtqueue_pop and unmap_buf == virtqueue_push.

Regards,

Anthony Liguori

  parent reply	other threads:[~2009-05-19 18:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-07 16:26 [PATCH v2] Driver for Inter-VM shared memory device for KVM supporting interrupts Cam Macdonell
2009-05-18 14:07 ` Christian Borntraeger
2009-05-18 14:26   ` Avi Kivity
2009-05-19  9:00     ` Christian Bornträger
2009-05-19  9:10       ` Avi Kivity
2009-05-19 16:51         ` Cam Macdonell
2009-05-20  2:58           ` Rusty Russell
2009-05-20  7:33             ` Christian Bornträger
2009-05-20  8:45               ` Avi Kivity
2009-05-20  9:07                 ` Christian Bornträger
2009-05-20  9:11                   ` Avi Kivity
2009-05-20  9:20                     ` Christian Bornträger
2009-05-25  6:18               ` Rusty Russell
2009-05-20  8:07             ` François Diakhate
2009-05-19 18:39       ` Anthony Liguori [this message]
2009-05-20  7:33         ` Christian Bornträger
2009-05-20 13:26           ` Anthony Liguori
2009-05-18 16:56   ` Cam Macdonell

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=4A12FCDC.5040008@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=avi@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cam@cs.ualberta.ca \
    --cc=ehrhardt@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.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.