Il 11/07/2014 11:23, Paolo Bonzini ha scritto:

+static struct virtqueue *vm_setup_vq(struct virtio_device *vdev,
+                     unsigned index,
+                     void (*callback)(struct virtqueue *vq),
+                     const char *name)
+{
+    struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
+    struct vring_virtqueue *vq;
+    void *queue;
+    unsigned num = VIRTIO_MMIO_QUEUE_NUM_MIN;
+
+    vq = alloc(sizeof(*vq));

You can move the allocation of vq to vm_find_vqs (interleaving alloc and
alloc_aligned causes some fragmentation), allocating a single block
instead of one per vq.

... or even use static storage for the "struct virtqueue". You can just merge "struct vring_virtqueue" and "struct virtqueue", as the idea of other virtqueue transport never materialized. Then:

+static struct virtqueue in_vq;
+static struct virtqueue out_vq;
+
 void chr_testdev_init(void)
 {
        const char *io_names[] = { "input", "output" };
-       struct virtqueue *vqs[2];
+       struct virtqueue *vqs[2] = { &in_vq, &out_vq };
        int ret;

        vcon = virtio_bind(VIRTIO_ID_CONSOLE);
        if (vcon == NULL) {
                printf("%s: %s: can't find a virtio-console\n",
                                __func__, TESTDEV_NAME);
                return;
        }

        ret = vcon->config->find_vqs(vcon, 2, vqs, NULL, io_names);
        if (ret < 0) {
                printf("%s: %s: can't init virtqueues\n",
                                __func__, TESTDEV_NAME);
                vcon = NULL;
                return;
        }

-       in_vq = vqs[0];
-       out_vq = vqs[1];
 }

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to