[Lguest] Communication between host and guest

Earlence Fernandes earlenceferns at gmail.com
Sat Jun 1 11:40:02 EST 2013


So I've spent some time studying the sources to the balloon driver and the
"vringh" implementation.
My understanding is that I will write a driver similar to the balloon in
terms of communication. That is, my driver
will initialize a virtqueue for incoming requests. It will initialize the
vq's using scatterlist init functions (as in the balloon driver).

Then my "device" in the host kernel will use the same functions as vringh
(or use vringh functions themselves?) to send
and receive data from the driver in the guest.

I don't understand how the vringh functions will get pointers to the
descriptors initialized in the guest?
Coz, for example, I guess I will have to use
int vringh_init_kern(struct vringh *vrh, u32 features,
     unsigned int num, bool weak_barriers,
     struct vring_desc *desc,
     struct vring_avail *avail,
     struct vring_used *used);

as an init function in my host "device". I think that these pointers are to
guest virtqueues, so how ill this function be called correctly?

-Earlence



On Wed, May 29, 2013 at 1:19 AM, Rusty Russell <rusty at rustcorp.com.au>wrote:

> Earlence Fernandes <earlenceferns at gmail.com> writes:
> > ok. so now I'm completely confused. vhost seems to be some sort of helper
> > driver.
> > What do I use?! There seems to be almost no documentation on this.
> >
> > What is the recommended method to bidirectionally communicate between
> host
> > and guest _kernels_ using the virtio API. And where
> > can I find easy to follow code examples.
>
> There isn't one, since lguest devices entirely work in userspace.  This
> is why you are confused :)
>
> vhost is an in-kernel accelerator but it relies on eventfds, but lguest
> doesn't use eventfds.  Thus vhost isn't really lguest compatible.  I
> looked at changing this, but it would make lguest more complicated.
>
> So you will need to intercept the LHCALL_NOTIFY code in the kernel, and
> if it's for your in-kernel device, handle it yourself.  Your in-kernel
> thread should be able to inject interrupts with user_send_irq(cpu, input);
>
> If you want to just hack something up, you can just use these directly
> and not use a virtio device.  Otherwise you need to handle a virtio
> device in the kernel: use drivers/vhost/vringh.c (despite the location,
> you can use it without vhost).
>
> Good luck!
> Rusty.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/lguest/attachments/20130531/46d179c6/attachment.html>


More information about the Lguest mailing list