<div dir="ltr">Ignore these emails. I figured the problem. I hadn't initialized the number of queues when calling find_vqs.<div><br></div><div>I think once I'm done figuring this whole thing out, I will write some documentation/tutorial on how to get it working properly.</div>

<div><br></div><div>-Earlence</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jun 9, 2013 at 6:19 PM, Earlence Fernandes <span dir="ltr"><<a href="mailto:earlenceferns@gmail.com" target="_blank">earlenceferns@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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.<span class="HOEnZb"><font color="#888888"><div>

<br></div><div>-Earlence</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sun, Jun 9, 2013 at 5:16 PM, Earlence Fernandes <span dir="ltr"><<a href="mailto:earlenceferns@gmail.com" target="_blank">earlenceferns@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div dir="ltr">This is the code for my probe function:<div><br></div><div><div>static int virtsyscalldev_probe(struct virtio_device *vdev)</div><div>{</div><div><span style="white-space:pre-wrap">      </span>struct virtio_syscalldev *vsdd;</div>



<div><span style="white-space:pre-wrap">  </span>struct virtqueue *vqs[1];</div><div><span style="white-space:pre-wrap">        </span>struct scatterlist sg[1];</div><div><span style="white-space:pre-wrap">        </span>int err, nvqs;</div>



<div><span style="white-space:pre-wrap">  </span></div><div><span style="white-space:pre-wrap"> </span>vq_callback_t *callbacks[] = { fromhost_dosyscall };</div><div><span style="white-space:pre-wrap">     </span>const char *names[] = { "dosyscall_q" };</div>



<div><span style="white-space:pre-wrap">  </span></div><div><span style="white-space:pre-wrap"> </span>vdev->priv = vsdd = kmalloc(sizeof(*vsdd), GFP_KERNEL);</div><div><span style="white-space:pre-wrap">       </span>if(!vsdd)</div>



<div><span style="white-space:pre-wrap">  </span>{</div><div><span style="white-space:pre-wrap">                </span>err = -ENOMEM;</div><div><span style="white-space:pre-wrap">           </span>goto out;</div><div><span style="white-space:pre-wrap">        </span>}</div>



<div><span style="white-space:pre-wrap">  </span></div><div><span style="white-space:pre-wrap"> </span>vsdd->vdev = vdev; //cache the virtio_device</div><div><span style="white-space:pre-wrap">  </span>err = vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names);</div>



<div><span style="white-space:pre-wrap">  </span>if(err)</div><div><span style="white-space:pre-wrap">          </span>goto out_free_vsdd;</div><div><span style="white-space:pre-wrap">              </span></div><div><span style="white-space:pre-wrap"> </span>vsdd->input_q = vqs[0];</div>



<div><span style="white-space:pre-wrap">  </span></div><div><span style="white-space:pre-wrap"> </span>/*</div><div><span style="white-space:pre-wrap">       </span>prime the input_q with a buffer so the hypervisor (host) can signal</div>



<div><span style="white-space:pre-wrap">  </span>us by placing data into it and inducing an interrupt</div><div><span style="white-space:pre-wrap">     </span>*/</div><div><span style="white-space:pre-wrap">       </span>sg_init_one(sg, vsdd->inbuff, sizeof(vsdd->inbuff));</div>



<div><span style="white-space:pre-wrap">  </span>printk(KERN_INFO "buffer ready to prime3\n");</div><div><span style="white-space:pre-wrap">  </span>if(virtqueue_add_buf(vsdd->input_q, sg, 0, 1, vsdd) < 0)</div>



<div><span style="white-space:pre-wrap">  </span>{</div><div><span style="white-space:pre-wrap">                </span>printk(KERN_ERR "OOOOOOOOOOOOPS\n");</div><div><span style="white-space:pre-wrap">                   </span>BUG();</div>
<div><span style="white-space:pre-wrap">  </span>}</div><div><span style="white-space:pre-wrap">                        </span></div><div><span style="white-space:pre-wrap"> </span>//buffer has been loaded in the vq, so now kick it</div>
<div><span style="white-space:pre-wrap">  </span>//and hence notify the hypervisor (host)</div><div><span style="white-space:pre-wrap"> </span>virtqueue_kick(vsdd->input_q);</div><div><span style="white-space:pre-wrap">        </span></div>



<div><span style="white-space:pre-wrap">  </span>return 0;</div><div><span style="white-space:pre-wrap">        </span></div><div>out_free_vsdd:</div><div><span style="white-space:pre-wrap">    </span>kfree(vsdd);</div><div>
out: </div><div><span style="white-space:pre-wrap"> </span>return err;</div><div>}</div></div><div><br></div><div>The syscalldev struct has a char buffer.</div><div>In the launcher, I created a single virtqueue like so:</div>



<div><br></div><div>add_virtqueue(dev, VIRTQUEUE_NUM, syscall_toguest);<br></div><div><br></div><div>I still get the BUG message. Any idea why?</div><span><font color="#888888"><div><br></div><div>-Earlence</div>
</font></span></div><div><div><div class="gmail_extra"><br><br>
<div class="gmail_quote">On Sat, Jun 8, 2013 at 11:38 PM, Earlence Fernandes <span dir="ltr"><<a href="mailto:earlenceferns@gmail.com" target="_blank">earlenceferns@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div dir="ltr">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.<div><br></div><div>Whenever I boot the system, lguest crashes complaining of a kernel BUG. At the line specified in virtio_ring.c, I see the following:</div>




<div><br></div><div>BUG_ON(out + in > vq->vring.num);<br></div><div><br></div><div>From this, it seems to me that I need more vrings than buffers.</div><div><br></div><div>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?</div>




<div><br></div><div>I've been following virtio_balloon as an example.</div><span><font color="#888888"><div><br></div><div>-Earlence</div></font></span></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>