The host needs to set up the virtqueue. This is an interim commit so suleiman can...
authorRonald G. Minnich <rminnich@gmail.com>
Thu, 13 Aug 2015 16:49:17 +0000 (09:49 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 2 Nov 2015 23:24:25 +0000 (18:24 -0500)
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tests/vmm/vmrunkernel.c
user/vmm/virtio-mmio.c
user/vmm/virtio_ring.c

index 86a6eeb..6eb4ade 100644 (file)
@@ -169,8 +169,8 @@ dev: VIRTIO_ID_CONSOLE,
 device_features: 0, /* Can't do it: linux console device does not support it. VIRTIO_F_VERSION_1*/
 numvqs: 2,
 vqs: {
-               {name: "consin", maxqnum: 2, f: &consin, arg: (void *)0},
-               {name: "consout", maxqnum: 2, f: consout, arg: (void *)0},
+               {name: "consin", maxqnum: 64, f: &consin, arg: (void *)0},
+               {name: "consout", maxqnum: 64, f: consout, arg: (void *)0},
        }
 };
 
index b3e9e30..2cbfc56 100644 (file)
@@ -296,7 +296,14 @@ static void virtio_mmio_write(uint64_t gpa, uint32_t value)
                    // let's kick off the thread and see how it goes?
                    struct virtio_threadarg *va = malloc(sizeof(*va));
                    va->arg = &mmio.vqdev->vqs[mmio.qsel];
-                   va->arg->virtio = (void *)(va->arg->pfn * mmio.pagesize);
+
+                   va->arg->virtio = vring_new_virtqueue(mmio.qsel, 
+                                                         mmio.vqdev->vqs[mmio.qsel].qnum,
+                                                         mmio.vqdev->vqs[mmio.qsel].qalign,
+                                                         false, // weak_barriers
+                                                         mmio.vqdev->vqs[mmio.qsel].pfn,
+                                                         NULL, NULL, /* callbacks */
+                                                         mmio.vqdev->vqs[mmio.qsel].name);
                    fprintf(stderr, "START THE THREAD. pfn is 0x%x, virtio is %p\n", mmio.pagesize, va->arg->virtio);
                    if (pthread_create(&va->arg->thread, NULL, va->arg->f, va)) {
                            fprintf(stderr, "pth_create failed for vq %s", va->arg->name);
index ee8a9d3..8c57297 100644 (file)
@@ -688,17 +688,20 @@ struct virtqueue *vring_new_virtqueue(unsigned int index,
                exit(1);
        }
 
+#if 0 // pretty sure this is wrong? Or not? 
        vq = mmap((int*)4096, sizeof(*vq) + sizeof(void *) * num + 2*PGSIZE, PROT_READ | PROT_WRITE,
                  MAP_ANONYMOUS, -1, 0);
        if (vq == MAP_FAILED) {
                perror("Unable to mmap vq");
                exit(1);
        }
-
-       fprintf(stderr, "VQ %p %d bytes \n", vq, sizeof(*vq) + sizeof(void *) * num + 2*PGSIZE);
+#endif
+       vq = pages;
+       fprintf(stderr, "VQ %p %d bytes \n", vq, num * vring_align); /* really? */
        if (!vq)
                return NULL;
 
+       // I *think* they correctly offset from vq for the vring? 
        vring_init(&vq->vring, num, pages, vring_align);
        fprintf(stderr, "done vring init\n");
        vq->vq.callback = callback;