[Lguest] Host -> Guest Virtqueue

Earlence Fernandes earlenceferns at gmail.com
Thu Jun 13 23:06:20 EST 2013


Yes. Now it works correctly. I'll write up some documentation on how to get
this done and post it.

-Earlence


On Wed, Jun 12, 2013 at 8:32 PM, Rusty Russell <rusty at rustcorp.com.au>wrote:

> Earlence Fernandes <earlenceferns at gmail.com> writes:
> > I am trying to achieve a host->guest comm channel.
> > so far, I have written a device in the launcher which simply registers
> one
> > IN vq and a handler function for the interrupt.
> > I have a virtio driver, which on initialization (probe), kmallocs a
> buffer,
> > calls sg_init_one, places the buffer via virtqueue_add_buf and then kicks
> > the vq.
> >
> > on the host side (launcher), my handler is called, and I can see the
> data I
> > had filled in on the guest side, however, when I try to set data into the
> > buffers by changing the iov[0].base to the addr of data in the host and
> try
> > a trigger_irq, my guest gets notified, but I don't see the updated data.
>
> Your Launcher code should look a little like the rng code, eg:
>
> static void mydev_input(struct virtqueue *vq)
> {
>         unsigned int head, in_num, out_num;
>         struct iovec iov[vq->vring.num];
>
>         /* First we need a buffer from the Guests's virtqueue. */
>         head = wait_for_vq_desc(vq, iov, &out_num, &in_num);
>         if (out_num)
>                 errx(1, "Output buffers in mydev?");
>
>         /*
>          * Just write into the first byte, to test.
>          */
>         memcpy(iov[0].iov_base, "A", 1);
>
>         /* Tell the Guest about the new input. */
>         add_used_and_trigger(vq, head, 1);
> }
>
> Cheers,
> Rusty.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/lguest/attachments/20130613/2ab0f1f4/attachment.html>


More information about the Lguest mailing list