[Lguest] Possible bug? adding only one buff to a vq with one input queue

Earlence Fernandes earlenceferns at gmail.com
Mon Jun 10 12:22:52 EST 2013


Ignore these emails. I figured the problem. I hadn't initialized the number
of queues when calling find_vqs.

I think once I'm done figuring this whole thing out, I will write some
documentation/tutorial on how to get it working properly.

-Earlence


On Sun, Jun 9, 2013 at 6:19 PM, Earlence Fernandes
<earlenceferns at gmail.com>wrote:

> I added a printk in virtio_ring.c near the BUG_ON check and the vring.num
> value is zero. I can't understand why.
>
> -Earlence
>
>
> On Sun, Jun 9, 2013 at 5:16 PM, Earlence Fernandes <
> earlenceferns at gmail.com> wrote:
>
>> This is the code for my probe function:
>>
>> static int virtsyscalldev_probe(struct virtio_device *vdev)
>> {
>> struct virtio_syscalldev *vsdd;
>>  struct virtqueue *vqs[1];
>> struct scatterlist sg[1];
>> int err, nvqs;
>>  vq_callback_t *callbacks[] = { fromhost_dosyscall };
>> const char *names[] = { "dosyscall_q" };
>>  vdev->priv = vsdd = kmalloc(sizeof(*vsdd), GFP_KERNEL);
>> if(!vsdd)
>>  {
>> err = -ENOMEM;
>> goto out;
>> }
>>  vsdd->vdev = vdev; //cache the virtio_device
>> err = vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names);
>>  if(err)
>> goto out_free_vsdd;
>>  vsdd->input_q = vqs[0];
>>  /*
>> prime the input_q with a buffer so the hypervisor (host) can signal
>>  us by placing data into it and inducing an interrupt
>> */
>> sg_init_one(sg, vsdd->inbuff, sizeof(vsdd->inbuff));
>>  printk(KERN_INFO "buffer ready to prime3\n");
>> if(virtqueue_add_buf(vsdd->input_q, sg, 0, 1, vsdd) < 0)
>>  {
>> printk(KERN_ERR "OOOOOOOOOOOOPS\n");
>> BUG();
>>  }
>>  //buffer has been loaded in the vq, so now kick it
>>  //and hence notify the hypervisor (host)
>> virtqueue_kick(vsdd->input_q);
>>  return 0;
>> out_free_vsdd:
>> kfree(vsdd);
>> out:
>> return err;
>> }
>>
>> The syscalldev struct has a char buffer.
>> In the launcher, I created a single virtqueue like so:
>>
>> add_virtqueue(dev, VIRTQUEUE_NUM, syscall_toguest);
>>
>> I still get the BUG message. Any idea why?
>>
>> -Earlence
>>
>>
>> On Sat, Jun 8, 2013 at 11:38 PM, Earlence Fernandes <
>> earlenceferns at gmail.com> wrote:
>>
>>> I am trying to achieve only host->guest communication and so I've
>>> created a virtio driver for the guest kernel which calls virtio_add_buf_gfp
>>> with one inbuf and 0 outbufs.
>>>
>>> Whenever I boot the system, lguest crashes complaining of a kernel BUG.
>>> At the line specified in virtio_ring.c, I see the following:
>>>
>>> BUG_ON(out + in > vq->vring.num);
>>>
>>> From this, it seems to me that I need more vrings than buffers.
>>>
>>> So, how do I have a channel from the host launcher to the guest kernel
>>> with only one queue which is used to send data exclusively into the guest?
>>>
>>> I've been following virtio_balloon as an example.
>>>
>>> -Earlence
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/lguest/attachments/20130609/1e1a8256/attachment.html>


More information about the Lguest mailing list