5 #include <sys/eventfd.h>
11 #include <sys/types.h>
14 #include <linux/virtio.h>
15 #include <linux/virtio_ring.h>
16 #include "../../drivers/vhost/test.h"
43 unsigned long long v = 1;
62 .avail_user_addr = (
uint64_t)(
unsigned long)info->
vring.avail,
91 r = posix_memalign(&info->
ring, 4096, vring_size(num, 4096));
94 vring_init(&info->
vring, num, info->
ring, 4096);
109 memset(dev, 0,
sizeof *dev);
111 dev->
vdev.features[1] = features >> 32;
120 sizeof dev->
mem->regions[0]);
123 sizeof dev->
mem->regions[0]);
124 dev->
mem->nregions = 1;
125 dev->
mem->regions[0].guest_phys_addr = (
long)dev->
buf;
126 dev->
mem->regions[0].userspace_addr = (
long)dev->
buf;
136 static void wait_for_interrupt(
struct vdev_info *dev)
139 unsigned long long val;
141 for (i = 0; i < dev->
nvqs; ++
i)
143 read(dev->
fds[i].fd, &val,
sizeof val);
152 long completed_before;
155 long long spurious = 0;
162 if (started < bufs) {
189 wait_for_interrupt(dev);
192 wait_for_interrupt(dev);
198 fprintf(stderr,
"spurious wakeus: 0x%llx\n", spurious);
212 .name =
"no-event-idx",
220 .name =
"no-indirect",
224 .name =
"delayed-interrupt",
228 .name =
"no-delayed-interrupt",
237 fprintf(stderr,
"Usage: virtio_test [--help]"
240 " [--delayed-interrupt]"
250 bool delayed =
false;
253 o = getopt_long(argc, argv, optstring, longopts,
NULL);
279 vdev_info_init(&dev, features);
280 vq_info_add(&dev, 256);
281 run_test(&dev, &dev.
vqs[0], delayed, 0x100000);