diff options
Diffstat (limited to 'tools/virtio/vringh_test.c')
| -rw-r--r-- | tools/virtio/vringh_test.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/tools/virtio/vringh_test.c b/tools/virtio/vringh_test.c index 6a48ca5c101..14a4f4cab5b 100644 --- a/tools/virtio/vringh_test.c +++ b/tools/virtio/vringh_test.c @@ -22,7 +22,7 @@ static u64 user_addr_offset; #define RINGSIZE 256 #define ALIGN 4096 -static void never_notify_host(struct virtqueue *vq) +static bool never_notify_host(struct virtqueue *vq) { abort(); } @@ -65,17 +65,22 @@ struct guest_virtio_device { unsigned long notifies; }; -static void parallel_notify_host(struct virtqueue *vq) +static bool parallel_notify_host(struct virtqueue *vq) { + int rc; struct guest_virtio_device *gvdev; gvdev = container_of(vq->vdev, struct guest_virtio_device, vdev); - write(gvdev->to_host_fd, "", 1); + rc = write(gvdev->to_host_fd, "", 1); + if (rc < 0) + return false; gvdev->notifies++; + return true; } -static void no_notify_host(struct virtqueue *vq) +static bool no_notify_host(struct virtqueue *vq) { + return true; } #define NUM_XFERS (10000000) @@ -369,11 +374,11 @@ static int parallel_test(unsigned long features, * user addr */ __kmalloc_fake = indirects + (xfers % RINGSIZE) * 4; if (output) - err = virtqueue_add_buf(vq, sg, num_sg, 0, dbuf, - GFP_KERNEL); + err = virtqueue_add_outbuf(vq, sg, num_sg, dbuf, + GFP_KERNEL); else - err = virtqueue_add_buf(vq, sg, 0, num_sg, dbuf, - GFP_KERNEL); + err = virtqueue_add_inbuf(vq, sg, num_sg, + dbuf, GFP_KERNEL); if (err == -ENOSPC) { if (!virtqueue_enable_cb_delayed(vq)) @@ -388,7 +393,7 @@ static int parallel_test(unsigned long features, } if (err) - errx(1, "virtqueue_add_buf: %i", err); + errx(1, "virtqueue_add_in/outbuf: %i", err); xfers++; virtqueue_kick(vq); @@ -431,7 +436,7 @@ int main(int argc, char *argv[]) struct virtio_device vdev; struct virtqueue *vq; struct vringh vrh; - struct scatterlist guest_sg[RINGSIZE]; + struct scatterlist guest_sg[RINGSIZE], *sgs[2]; struct iovec host_riov[2], host_wiov[2]; struct vringh_iov riov, wiov; struct vring_used_elem used[RINGSIZE]; @@ -492,12 +497,14 @@ int main(int argc, char *argv[]) sg_set_buf(&guest_sg[0], __user_addr_max - 1, 1); sg_init_table(guest_sg+1, 1); sg_set_buf(&guest_sg[1], __user_addr_max - 3, 2); + sgs[0] = &guest_sg[0]; + sgs[1] = &guest_sg[1]; /* May allocate an indirect, so force it to allocate user addr */ __kmalloc_fake = __user_addr_min + vring_size(RINGSIZE, ALIGN); - err = virtqueue_add_buf(vq, guest_sg, 1, 1, &err, GFP_KERNEL); + err = virtqueue_add_sgs(vq, sgs, 1, 1, &err, GFP_KERNEL); if (err) - errx(1, "virtqueue_add_buf: %i", err); + errx(1, "virtqueue_add_sgs: %i", err); __kmalloc_fake = NULL; /* Host retreives it. */ @@ -564,9 +571,9 @@ int main(int argc, char *argv[]) /* This will allocate an indirect, so force it to allocate user addr */ __kmalloc_fake = __user_addr_min + vring_size(RINGSIZE, ALIGN); - err = virtqueue_add_buf(vq, guest_sg, RINGSIZE, 0, &err, GFP_KERNEL); + err = virtqueue_add_outbuf(vq, guest_sg, RINGSIZE, &err, GFP_KERNEL); if (err) - errx(1, "virtqueue_add_buf (large): %i", err); + errx(1, "virtqueue_add_outbuf (large): %i", err); __kmalloc_fake = NULL; /* Host picks it up (allocates new iov). */ @@ -616,9 +623,9 @@ int main(int argc, char *argv[]) sg_init_table(guest_sg, 1); sg_set_buf(&guest_sg[0], __user_addr_max - 1, 1); for (i = 0; i < RINGSIZE; i++) { - err = virtqueue_add_buf(vq, guest_sg, 1, 0, &err, GFP_KERNEL); + err = virtqueue_add_outbuf(vq, guest_sg, 1, &err, GFP_KERNEL); if (err) - errx(1, "virtqueue_add_buf (multiple): %i", err); + errx(1, "virtqueue_add_outbuf (multiple): %i", err); } /* Now get many, and consume them all at once. */ @@ -664,9 +671,9 @@ int main(int argc, char *argv[]) sg_set_buf(&guest_sg[2], data + 6, 4); sg_set_buf(&guest_sg[3], d + 3, sizeof(*d)*3); - err = virtqueue_add_buf(vq, guest_sg, 4, 0, &err, GFP_KERNEL); + err = virtqueue_add_outbuf(vq, guest_sg, 4, &err, GFP_KERNEL); if (err) - errx(1, "virtqueue_add_buf (indirect): %i", err); + errx(1, "virtqueue_add_outbuf (indirect): %i", err); vring_init(&vring, RINGSIZE, __user_addr_min, ALIGN); |
