tools/virtio: add vring_test.
[linux-3.10.git] / tools / virtio / virtio_test.c
index 6d25dcd..814ae80 100644 (file)
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <fcntl.h>
+#include <stdbool.h>
 #include <linux/vhost.h>
 #include <linux/virtio.h>
 #include <linux/virtio_ring.h>
 #include "../../drivers/vhost/test.h"
 
+/* Unused */
+void *__kmalloc_fake, *__kfree_ignore_start, *__kfree_ignore_end;
+
 struct vq_info {
        int kick;
        int call;
@@ -92,7 +96,8 @@ static void vq_info_add(struct vdev_info *dev, int num)
        assert(r >= 0);
        memset(info->ring, 0, vring_size(num, 4096));
        vring_init(&info->vring, num, info->ring, 4096);
-       info->vq = vring_new_virtqueue(info->vring.num, 4096, &dev->vdev,
+       info->vq = vring_new_virtqueue(info->idx,
+                                      info->vring.num, 4096, &dev->vdev,
                                       true, info->ring,
                                       vq_notify, vq_callback, "test");
        assert(info->vq);
@@ -164,7 +169,7 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq,
                                r = virtqueue_add_buf(vq->vq, &sl, 1, 0,
                                                      dev->buf + started,
                                                      GFP_ATOMIC);
-                               if (likely(r >= 0)) {
+                               if (likely(r == 0)) {
                                        ++started;
                                        virtqueue_kick(vq->vq);
                                }
@@ -177,7 +182,7 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq,
                                r = 0;
                        }
 
-               } while (r >= 0);
+               } while (r == 0);
                if (completed == completed_before)
                        ++spurious;
                assert(completed <= bufs);