[Lguest] Communication between host and guest

Rusty Russell rusty at rustcorp.com.au
Wed May 29 15:19:47 EST 2013


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.


More information about the Lguest mailing list