This patch implements a virtio-based transport for use by a virtualised OpenGL passthrough implementation.
The libGL and qemu-gl code to support this patch are available here:
http://gitorious.org/vm-gl-accel/qemu-gl
http://gitorious.org/vm-gl-accel/qemu-libgl
Comments please!
+static int put_data(struct virtio_gl_data *gldata)
+{
+ struct scatterlist *sg, *sg_list;
+ unsigned int count, ret, o_page, i_page, sg_entries;
+ struct virtio_gl_header *header =
+ (struct virtio_gl_header *)gldata->buffer;
+
+ ret = header->buf_size;
+
+ o_page = (header->buf_size + PAGE_SIZE-1)>> PAGE_SHIFT;
+ sg_init_table(sg_list, sg_entries);
+
+ sg = vmalloc_to_sg(sg_list, gldata->buffer, o_page);
+ sg = vmalloc_to_sg(sg, gldata->buffer, i_page);
+
+ if (!sg) {
+ ret = -EIO;
+ goto out_free;
+ }
+
+ /* Transfer data */
+ if (virtqueue_add_buf(vq, sg_list, o_page, i_page, (void *)1)>= 0) {
+ virtqueue_kick(vq);
+ /* Chill out until it's done with the buffer. */
+ while (!virtqueue_get_buf(vq,&count))
+ cpu_relax();
+ }
+