<div dir="ltr">So I've spent some time studying the sources to the balloon driver and the "vringh" implementation.<div>My understanding is that I will write a driver similar to the balloon in terms of communication. That is, my driver</div>

<div>will initialize a virtqueue for incoming requests. It will initialize the vq's using scatterlist init functions (as in the balloon driver).</div><div><br></div><div>Then my "device" in the host kernel will use the same functions as vringh (or use vringh functions themselves?) to send</div>

<div>and receive data from the driver in the guest.</div><div><br></div><div>I don't understand how the vringh functions will get pointers to the descriptors initialized in the guest?</div><div>Coz, for example, I guess I will have to use </div>

<div><div>int vringh_init_kern(struct vringh *vrh, u32 features,</div><div><span class="" style="white-space:pre">            </span>     unsigned int num, bool weak_barriers,</div><div><span class="" style="white-space:pre">         </span>     struct vring_desc *desc,</div>

<div><span class="" style="white-space:pre">            </span>     struct vring_avail *avail,</div><div><span class="" style="white-space:pre">            </span>     struct vring_used *used);</div></div><div><br></div><div>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?</div>

<div><br></div><div>-Earlence</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 29, 2013 at 1:19 AM, Rusty Russell <span dir="ltr"><<a href="mailto:rusty@rustcorp.com.au" target="_blank">rusty@rustcorp.com.au</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">Earlence Fernandes <<a href="mailto:earlenceferns@gmail.com">earlenceferns@gmail.com</a>> writes:<br>


> ok. so now I'm completely confused. vhost seems to be some sort of helper<br>
> driver.<br>
> What do I use?! There seems to be almost no documentation on this.<br>
><br>
> What is the recommended method to bidirectionally communicate between host<br>
> and guest _kernels_ using the virtio API. And where<br>
> can I find easy to follow code examples.<br>
<br>
</div>There isn't one, since lguest devices entirely work in userspace.  This<br>
is why you are confused :)<br>
<br>
vhost is an in-kernel accelerator but it relies on eventfds, but lguest<br>
doesn't use eventfds.  Thus vhost isn't really lguest compatible.  I<br>
looked at changing this, but it would make lguest more complicated.<br>
<br>
So you will need to intercept the LHCALL_NOTIFY code in the kernel, and<br>
if it's for your in-kernel device, handle it yourself.  Your in-kernel<br>
thread should be able to inject interrupts with user_send_irq(cpu, input);<br>
<br>
If you want to just hack something up, you can just use these directly<br>
and not use a virtio device.  Otherwise you need to handle a virtio<br>
device in the kernel: use drivers/vhost/vringh.c (despite the location,<br>
you can use it without vhost).<br>
<br>
Good luck!<br>
<span class="HOEnZb"><font color="#888888">Rusty.<br>
</font></span></blockquote></div><br></div>