[Lguest] Host -> Guest Virtqueue

Rusty Russell rusty at rustcorp.com.au
Thu Jun 13 10:32:34 EST 2013


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.


More information about the Lguest mailing list