<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 class="" style="white-space:pre">        </span>struct virtio_syscalldev *vsdd;</div>

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

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

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

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

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

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

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

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

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

<div><span class="" style="white-space:pre">    </span>{</div><div><span class="" style="white-space:pre">          </span>printk(KERN_ERR "OOOOOOOOOOOOPS\n");</div><div><span class="" style="white-space:pre">                     </span>BUG();</div>

<div><span class="" style="white-space:pre">    </span>}</div><div><span class="" style="white-space:pre">                  </span></div><div><span class="" style="white-space:pre">   </span>//buffer has been loaded in the vq, so now kick it</div>

<div><span class="" style="white-space:pre">    </span>//and hence notify the hypervisor (host)</div><div><span class="" style="white-space:pre">   </span>virtqueue_kick(vsdd->input_q);</div><div><span class="" style="white-space:pre">  </span></div>

<div><span class="" style="white-space:pre">    </span>return 0;</div><div><span class="" style="white-space:pre">  </span></div><div>out_free_vsdd:</div><div><span class="" style="white-space:pre">      </span>kfree(vsdd);</div>
<div>
out: </div><div><span class="" style="white-space:pre">   </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><div><br></div><div>-Earlence</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 class="HOEnZb"><font color="#888888"><div><br></div><div>-Earlence</div></font></span></div>
</blockquote></div><br></div>