1 /* Simple test of virtio code, entirely in userpsace. */
5 #include <linux/kernel.h>
7 #include <linux/virtio.h>
8 #include <linux/vringh.h>
9 #include <linux/virtio_ring.h>
10 #include <linux/virtio_config.h>
11 #include <linux/uaccess.h>
12 #include <sys/types.h>
18 #define USER_MEM (1024*1024)
19 void *__user_addr_min
, *__user_addr_max
;
20 void *__kmalloc_fake
, *__kfree_ignore_start
, *__kfree_ignore_end
;
21 static u64 user_addr_offset
;
26 static bool never_notify_host(struct virtqueue
*vq
)
31 static void never_callback_guest(struct virtqueue
*vq
)
36 static bool getrange_iov(struct vringh
*vrh
, u64 addr
, struct vringh_range
*r
)
38 if (addr
< (u64
)(unsigned long)__user_addr_min
- user_addr_offset
)
40 if (addr
>= (u64
)(unsigned long)__user_addr_max
- user_addr_offset
)
43 r
->start
= (u64
)(unsigned long)__user_addr_min
- user_addr_offset
;
44 r
->end_incl
= (u64
)(unsigned long)__user_addr_max
- 1 - user_addr_offset
;
45 r
->offset
= user_addr_offset
;
49 /* We return single byte ranges. */
50 static bool getrange_slow(struct vringh
*vrh
, u64 addr
, struct vringh_range
*r
)
52 if (addr
< (u64
)(unsigned long)__user_addr_min
- user_addr_offset
)
54 if (addr
>= (u64
)(unsigned long)__user_addr_max
- user_addr_offset
)
58 r
->end_incl
= r
->start
;
59 r
->offset
= user_addr_offset
;
63 struct guest_virtio_device
{
64 struct virtio_device vdev
;
66 unsigned long notifies
;
69 static bool parallel_notify_host(struct virtqueue
*vq
)
72 struct guest_virtio_device
*gvdev
;
74 gvdev
= container_of(vq
->vdev
, struct guest_virtio_device
, vdev
);
75 rc
= write(gvdev
->to_host_fd
, "", 1);
82 static bool no_notify_host(struct virtqueue
*vq
)
87 #define NUM_XFERS (10000000)
89 /* We aim for two "distant" cpus. */
90 static void find_cpus(unsigned int *first
, unsigned int *last
)
96 for (i
= 0; i
< 4096; i
++) {
100 if (sched_setaffinity(getpid(), sizeof(set
), &set
) == 0) {
109 /* Opencoded version for fast mode */
110 static inline int vringh_get_head(struct vringh
*vrh
, u16
*head
)
115 err
= get_user(avail_idx
, &vrh
->vring
.avail
->idx
);
119 if (vrh
->last_avail_idx
== avail_idx
)
122 /* Only get avail ring entries after they have been exposed by guest. */
123 virtio_rmb(vrh
->weak_barriers
);
125 i
= vrh
->last_avail_idx
& (vrh
->vring
.num
- 1);
127 err
= get_user(*head
, &vrh
->vring
.avail
->ring
[i
]);
131 vrh
->last_avail_idx
++;
135 static int parallel_test(u64 features
,
136 bool (*getrange
)(struct vringh
*vrh
,
137 u64 addr
, struct vringh_range
*r
),
140 void *host_map
, *guest_map
;
141 int fd
, mapsize
, to_guest
[2], to_host
[2];
142 unsigned long xfers
= 0, notifies
= 0, receives
= 0;
143 unsigned int first_cpu
, last_cpu
;
147 /* Create real file to mmap. */
148 fd
= open("/tmp/vringh_test-file", O_RDWR
|O_CREAT
|O_TRUNC
, 0600);
150 err(1, "Opening /tmp/vringh_test-file");
152 /* Extra room at the end for some data, and indirects */
153 mapsize
= vring_size(RINGSIZE
, ALIGN
)
154 + RINGSIZE
* 2 * sizeof(int)
155 + RINGSIZE
* 6 * sizeof(struct vring_desc
);
156 mapsize
= (mapsize
+ getpagesize() - 1) & ~(getpagesize() - 1);
157 ftruncate(fd
, mapsize
);
159 /* Parent and child use separate addresses, to check our mapping logic! */
160 host_map
= mmap(NULL
, mapsize
, PROT_READ
|PROT_WRITE
, MAP_SHARED
, fd
, 0);
161 guest_map
= mmap(NULL
, mapsize
, PROT_READ
|PROT_WRITE
, MAP_SHARED
, fd
, 0);
167 find_cpus(&first_cpu
, &last_cpu
);
168 printf("Using CPUS %u and %u\n", first_cpu
, last_cpu
);
173 int status
, err
, rlen
= 0;
176 /* We are the host: never access guest addresses! */
177 munmap(guest_map
, mapsize
);
179 __user_addr_min
= host_map
;
180 __user_addr_max
= __user_addr_min
+ mapsize
;
181 user_addr_offset
= host_map
- guest_map
;
182 assert(user_addr_offset
);
187 vring_init(&vrh
.vring
, RINGSIZE
, host_map
, ALIGN
);
188 vringh_init_user(&vrh
, features
, RINGSIZE
, true,
189 vrh
.vring
.desc
, vrh
.vring
.avail
, vrh
.vring
.used
);
190 CPU_SET(first_cpu
, &cpu_set
);
191 if (sched_setaffinity(getpid(), sizeof(cpu_set
), &cpu_set
))
192 errx(1, "Could not set affinity to cpu %u", first_cpu
);
194 while (xfers
< NUM_XFERS
) {
195 struct iovec host_riov
[2], host_wiov
[2];
196 struct vringh_iov riov
, wiov
;
201 err
= vringh_get_head(&vrh
, &head
);
204 err
= vringh_need_notify_user(&vrh
);
206 errx(1, "vringh_need_notify_user: %i",
209 write(to_guest
[1], "", 1);
214 errx(1, "vringh_get_head");
218 vringh_iov_init(&riov
,
220 ARRAY_SIZE(host_riov
));
221 vringh_iov_init(&wiov
,
223 ARRAY_SIZE(host_wiov
));
225 err
= vringh_getdesc_user(&vrh
, &riov
, &wiov
,
229 err
= vringh_need_notify_user(&vrh
);
231 errx(1, "vringh_need_notify_user: %i",
234 write(to_guest
[1], "", 1);
238 if (!vringh_notify_enable_user(&vrh
))
241 /* Swallow all notifies at once. */
242 if (read(to_host
[0], buf
, sizeof(buf
)) < 1)
245 vringh_notify_disable_user(&vrh
);
250 errx(1, "vringh_getdesc_user: %i", err
);
252 /* We simply copy bytes. */
254 rlen
= vringh_iov_pull_user(&riov
, rbuf
,
257 errx(1, "vringh_iov_pull_user: %i",
259 assert(riov
.i
== riov
.used
);
262 err
= vringh_iov_push_user(&wiov
, rbuf
, rlen
);
264 errx(1, "vringh_iov_push_user: %i",
266 assert(wiov
.i
== wiov
.used
);
272 err
= vringh_complete_user(&vrh
, head
, written
);
274 errx(1, "vringh_complete_user: %i", err
);
277 err
= vringh_need_notify_user(&vrh
);
279 errx(1, "vringh_need_notify_user: %i", err
);
281 write(to_guest
[1], "", 1);
285 if (!WIFEXITED(status
))
286 errx(1, "Child died with signal %i?", WTERMSIG(status
));
287 if (WEXITSTATUS(status
) != 0)
288 errx(1, "Child exited %i?", WEXITSTATUS(status
));
289 printf("Host: notified %lu, pinged %lu\n", notifies
, receives
);
292 struct guest_virtio_device gvdev
;
293 struct virtqueue
*vq
;
295 struct vring_desc
*indirects
;
296 unsigned int finished
= 0;
298 /* We pass sg[]s pointing into here, but we need RINGSIZE+1 */
299 data
= guest_map
+ vring_size(RINGSIZE
, ALIGN
);
300 indirects
= (void *)data
+ (RINGSIZE
+ 1) * 2 * sizeof(int);
302 /* We are the guest. */
303 munmap(host_map
, mapsize
);
308 gvdev
.vdev
.features
= features
;
309 gvdev
.to_host_fd
= to_host
[1];
312 CPU_SET(first_cpu
, &cpu_set
);
313 if (sched_setaffinity(getpid(), sizeof(cpu_set
), &cpu_set
))
314 err(1, "Could not set affinity to cpu %u", first_cpu
);
316 vq
= vring_new_virtqueue(0, RINGSIZE
, ALIGN
, &gvdev
.vdev
, true,
317 guest_map
, fast_vringh
? no_notify_host
318 : parallel_notify_host
,
319 never_callback_guest
, "guest vq");
321 /* Don't kfree indirects. */
322 __kfree_ignore_start
= indirects
;
323 __kfree_ignore_end
= indirects
+ RINGSIZE
* 6;
325 while (xfers
< NUM_XFERS
) {
326 struct scatterlist sg
[4];
327 unsigned int num_sg
, len
;
329 bool output
= !(xfers
% 2);
332 while ((dbuf
= virtqueue_get_buf(vq
, &len
)) != NULL
) {
334 assert(*dbuf
== finished
- 1);
335 else if (!fast_vringh
)
336 assert(*dbuf
== finished
);
340 /* Produce a buffer. */
341 dbuf
= data
+ (xfers
% (RINGSIZE
+ 1));
348 switch ((xfers
/ sizeof(*dbuf
)) % 4) {
350 /* Nasty three-element sg list. */
351 sg_init_table(sg
, num_sg
= 3);
352 sg_set_buf(&sg
[0], (void *)dbuf
, 1);
353 sg_set_buf(&sg
[1], (void *)dbuf
+ 1, 2);
354 sg_set_buf(&sg
[2], (void *)dbuf
+ 3, 1);
357 sg_init_table(sg
, num_sg
= 2);
358 sg_set_buf(&sg
[0], (void *)dbuf
, 1);
359 sg_set_buf(&sg
[1], (void *)dbuf
+ 1, 3);
362 sg_init_table(sg
, num_sg
= 1);
363 sg_set_buf(&sg
[0], (void *)dbuf
, 4);
366 sg_init_table(sg
, num_sg
= 4);
367 sg_set_buf(&sg
[0], (void *)dbuf
, 1);
368 sg_set_buf(&sg
[1], (void *)dbuf
+ 1, 1);
369 sg_set_buf(&sg
[2], (void *)dbuf
+ 2, 1);
370 sg_set_buf(&sg
[3], (void *)dbuf
+ 3, 1);
374 /* May allocate an indirect, so force it to allocate
376 __kmalloc_fake
= indirects
+ (xfers
% RINGSIZE
) * 4;
378 err
= virtqueue_add_outbuf(vq
, sg
, num_sg
, dbuf
,
381 err
= virtqueue_add_inbuf(vq
, sg
, num_sg
,
384 if (err
== -ENOSPC
) {
385 if (!virtqueue_enable_cb_delayed(vq
))
387 /* Swallow all notifies at once. */
388 if (read(to_guest
[0], buf
, sizeof(buf
)) < 1)
392 virtqueue_disable_cb(vq
);
397 errx(1, "virtqueue_add_in/outbuf: %i", err
);
404 while (finished
!= xfers
) {
409 dbuf
= virtqueue_get_buf(vq
, &len
);
412 assert(*dbuf
== finished
- 1);
419 if (!virtqueue_enable_cb_delayed(vq
))
421 if (read(to_guest
[0], buf
, sizeof(buf
)) < 1)
425 virtqueue_disable_cb(vq
);
428 printf("Guest: notified %lu, pinged %lu\n",
429 gvdev
.notifies
, receives
);
430 vring_del_virtqueue(vq
);
435 int main(int argc
, char *argv
[])
437 struct virtio_device vdev
;
438 struct virtqueue
*vq
;
440 struct scatterlist guest_sg
[RINGSIZE
], *sgs
[2];
441 struct iovec host_riov
[2], host_wiov
[2];
442 struct vringh_iov riov
, wiov
;
443 struct vring_used_elem used
[RINGSIZE
];
449 bool (*getrange
)(struct vringh
*vrh
, u64 addr
, struct vringh_range
*r
);
450 bool fast_vringh
= false, parallel
= false;
452 getrange
= getrange_iov
;
456 if (strcmp(argv
[1], "--indirect") == 0)
457 __virtio_set_bit(&vdev
, VIRTIO_RING_F_INDIRECT_DESC
);
458 else if (strcmp(argv
[1], "--eventidx") == 0)
459 __virtio_set_bit(&vdev
, VIRTIO_RING_F_EVENT_IDX
);
460 else if (strcmp(argv
[1], "--virtio-1") == 0)
461 __virtio_set_bit(&vdev
, VIRTIO_F_VERSION_1
);
462 else if (strcmp(argv
[1], "--slow-range") == 0)
463 getrange
= getrange_slow
;
464 else if (strcmp(argv
[1], "--fast-vringh") == 0)
466 else if (strcmp(argv
[1], "--parallel") == 0)
469 errx(1, "Unknown arg %s", argv
[1]);
474 return parallel_test(vdev
.features
, getrange
, fast_vringh
);
476 if (posix_memalign(&__user_addr_min
, PAGE_SIZE
, USER_MEM
) != 0)
478 __user_addr_max
= __user_addr_min
+ USER_MEM
;
479 memset(__user_addr_min
, 0, vring_size(RINGSIZE
, ALIGN
));
481 /* Set up guest side. */
482 vq
= vring_new_virtqueue(0, RINGSIZE
, ALIGN
, &vdev
, true,
484 never_notify_host
, never_callback_guest
,
487 /* Set up host side. */
488 vring_init(&vrh
.vring
, RINGSIZE
, __user_addr_min
, ALIGN
);
489 vringh_init_user(&vrh
, vdev
.features
, RINGSIZE
, true,
490 vrh
.vring
.desc
, vrh
.vring
.avail
, vrh
.vring
.used
);
492 /* No descriptor to get yet... */
493 err
= vringh_getdesc_user(&vrh
, &riov
, &wiov
, getrange
, &head
);
495 errx(1, "vringh_getdesc_user: %i", err
);
497 /* Guest puts in a descriptor. */
498 memcpy(__user_addr_max
- 1, "a", 1);
499 sg_init_table(guest_sg
, 1);
500 sg_set_buf(&guest_sg
[0], __user_addr_max
- 1, 1);
501 sg_init_table(guest_sg
+1, 1);
502 sg_set_buf(&guest_sg
[1], __user_addr_max
- 3, 2);
503 sgs
[0] = &guest_sg
[0];
504 sgs
[1] = &guest_sg
[1];
506 /* May allocate an indirect, so force it to allocate user addr */
507 __kmalloc_fake
= __user_addr_min
+ vring_size(RINGSIZE
, ALIGN
);
508 err
= virtqueue_add_sgs(vq
, sgs
, 1, 1, &err
, GFP_KERNEL
);
510 errx(1, "virtqueue_add_sgs: %i", err
);
511 __kmalloc_fake
= NULL
;
513 /* Host retreives it. */
514 vringh_iov_init(&riov
, host_riov
, ARRAY_SIZE(host_riov
));
515 vringh_iov_init(&wiov
, host_wiov
, ARRAY_SIZE(host_wiov
));
517 err
= vringh_getdesc_user(&vrh
, &riov
, &wiov
, getrange
, &head
);
519 errx(1, "vringh_getdesc_user: %i", err
);
521 assert(riov
.used
== 1);
522 assert(riov
.iov
[0].iov_base
== __user_addr_max
- 1);
523 assert(riov
.iov
[0].iov_len
== 1);
524 if (getrange
!= getrange_slow
) {
525 assert(wiov
.used
== 1);
526 assert(wiov
.iov
[0].iov_base
== __user_addr_max
- 3);
527 assert(wiov
.iov
[0].iov_len
== 2);
529 assert(wiov
.used
== 2);
530 assert(wiov
.iov
[0].iov_base
== __user_addr_max
- 3);
531 assert(wiov
.iov
[0].iov_len
== 1);
532 assert(wiov
.iov
[1].iov_base
== __user_addr_max
- 2);
533 assert(wiov
.iov
[1].iov_len
== 1);
536 err
= vringh_iov_pull_user(&riov
, buf
, 5);
538 errx(1, "vringh_iov_pull_user: %i", err
);
539 assert(buf
[0] == 'a');
541 assert(vringh_iov_pull_user(&riov
, buf
, 5) == 0);
543 memcpy(buf
, "bcdef", 5);
544 err
= vringh_iov_push_user(&wiov
, buf
, 5);
546 errx(1, "vringh_iov_push_user: %i", err
);
547 assert(memcmp(__user_addr_max
- 3, "bc", 2) == 0);
548 assert(wiov
.i
== wiov
.used
);
549 assert(vringh_iov_push_user(&wiov
, buf
, 5) == 0);
552 err
= vringh_complete_user(&vrh
, head
, err
);
554 errx(1, "vringh_complete_user: %i", err
);
556 /* Guest should see used token now. */
557 __kfree_ignore_start
= __user_addr_min
+ vring_size(RINGSIZE
, ALIGN
);
558 __kfree_ignore_end
= __kfree_ignore_start
+ 1;
559 ret
= virtqueue_get_buf(vq
, &i
);
561 errx(1, "virtqueue_get_buf: %p", ret
);
564 /* Guest puts in a huge descriptor. */
565 sg_init_table(guest_sg
, RINGSIZE
);
566 for (i
= 0; i
< RINGSIZE
; i
++) {
567 sg_set_buf(&guest_sg
[i
],
568 __user_addr_max
- USER_MEM
/4, USER_MEM
/4);
571 /* Fill contents with recognisable garbage. */
572 for (i
= 0; i
< USER_MEM
/4; i
++)
573 ((char *)__user_addr_max
- USER_MEM
/4)[i
] = i
;
575 /* This will allocate an indirect, so force it to allocate user addr */
576 __kmalloc_fake
= __user_addr_min
+ vring_size(RINGSIZE
, ALIGN
);
577 err
= virtqueue_add_outbuf(vq
, guest_sg
, RINGSIZE
, &err
, GFP_KERNEL
);
579 errx(1, "virtqueue_add_outbuf (large): %i", err
);
580 __kmalloc_fake
= NULL
;
582 /* Host picks it up (allocates new iov). */
583 vringh_iov_init(&riov
, host_riov
, ARRAY_SIZE(host_riov
));
584 vringh_iov_init(&wiov
, host_wiov
, ARRAY_SIZE(host_wiov
));
586 err
= vringh_getdesc_user(&vrh
, &riov
, &wiov
, getrange
, &head
);
588 errx(1, "vringh_getdesc_user: %i", err
);
590 assert(riov
.max_num
& VRINGH_IOV_ALLOCATED
);
591 assert(riov
.iov
!= host_riov
);
592 if (getrange
!= getrange_slow
)
593 assert(riov
.used
== RINGSIZE
);
595 assert(riov
.used
== RINGSIZE
* USER_MEM
/4);
597 assert(!(wiov
.max_num
& VRINGH_IOV_ALLOCATED
));
598 assert(wiov
.used
== 0);
600 /* Pull data back out (in odd chunks), should be as expected. */
601 for (i
= 0; i
< RINGSIZE
* USER_MEM
/4; i
+= 3) {
602 err
= vringh_iov_pull_user(&riov
, buf
, 3);
603 if (err
!= 3 && i
+ err
!= RINGSIZE
* USER_MEM
/4)
604 errx(1, "vringh_iov_pull_user large: %i", err
);
605 assert(buf
[0] == (char)i
);
606 assert(err
< 2 || buf
[1] == (char)(i
+ 1));
607 assert(err
< 3 || buf
[2] == (char)(i
+ 2));
609 assert(riov
.i
== riov
.used
);
610 vringh_iov_cleanup(&riov
);
611 vringh_iov_cleanup(&wiov
);
613 /* Complete using multi interface, just because we can. */
616 err
= vringh_complete_multi_user(&vrh
, used
, 1);
618 errx(1, "vringh_complete_multi_user(1): %i", err
);
620 /* Free up those descriptors. */
621 ret
= virtqueue_get_buf(vq
, &i
);
623 errx(1, "virtqueue_get_buf: %p", ret
);
625 /* Add lots of descriptors. */
626 sg_init_table(guest_sg
, 1);
627 sg_set_buf(&guest_sg
[0], __user_addr_max
- 1, 1);
628 for (i
= 0; i
< RINGSIZE
; i
++) {
629 err
= virtqueue_add_outbuf(vq
, guest_sg
, 1, &err
, GFP_KERNEL
);
631 errx(1, "virtqueue_add_outbuf (multiple): %i", err
);
634 /* Now get many, and consume them all at once. */
635 vringh_iov_init(&riov
, host_riov
, ARRAY_SIZE(host_riov
));
636 vringh_iov_init(&wiov
, host_wiov
, ARRAY_SIZE(host_wiov
));
638 for (i
= 0; i
< RINGSIZE
; i
++) {
639 err
= vringh_getdesc_user(&vrh
, &riov
, &wiov
, getrange
, &head
);
641 errx(1, "vringh_getdesc_user: %i", err
);
645 /* Make sure it wraps around ring, to test! */
646 assert(vrh
.vring
.used
->idx
% RINGSIZE
!= 0);
647 err
= vringh_complete_multi_user(&vrh
, used
, RINGSIZE
);
649 errx(1, "vringh_complete_multi_user: %i", err
);
651 /* Free those buffers. */
652 for (i
= 0; i
< RINGSIZE
; i
++) {
654 assert(virtqueue_get_buf(vq
, &len
) != NULL
);
657 /* Test weird (but legal!) indirect. */
658 if (__virtio_test_bit(&vdev
, VIRTIO_RING_F_INDIRECT_DESC
)) {
659 char *data
= __user_addr_max
- USER_MEM
/4;
660 struct vring_desc
*d
= __user_addr_max
- USER_MEM
/2;
663 /* Force creation of direct, which we modify. */
664 __virtio_clear_bit(&vdev
, VIRTIO_RING_F_INDIRECT_DESC
);
665 vq
= vring_new_virtqueue(0, RINGSIZE
, ALIGN
, &vdev
, true,
668 never_callback_guest
,
671 sg_init_table(guest_sg
, 4);
672 sg_set_buf(&guest_sg
[0], d
, sizeof(*d
)*2);
673 sg_set_buf(&guest_sg
[1], d
+ 2, sizeof(*d
)*1);
674 sg_set_buf(&guest_sg
[2], data
+ 6, 4);
675 sg_set_buf(&guest_sg
[3], d
+ 3, sizeof(*d
)*3);
677 err
= virtqueue_add_outbuf(vq
, guest_sg
, 4, &err
, GFP_KERNEL
);
679 errx(1, "virtqueue_add_outbuf (indirect): %i", err
);
681 vring_init(&vring
, RINGSIZE
, __user_addr_min
, ALIGN
);
683 /* They're used in order, but double-check... */
684 assert(vring
.desc
[0].addr
== (unsigned long)d
);
685 assert(vring
.desc
[1].addr
== (unsigned long)(d
+2));
686 assert(vring
.desc
[2].addr
== (unsigned long)data
+ 6);
687 assert(vring
.desc
[3].addr
== (unsigned long)(d
+3));
688 vring
.desc
[0].flags
|= VRING_DESC_F_INDIRECT
;
689 vring
.desc
[1].flags
|= VRING_DESC_F_INDIRECT
;
690 vring
.desc
[3].flags
|= VRING_DESC_F_INDIRECT
;
693 d
[0].addr
= (unsigned long)data
;
695 d
[0].flags
= VRING_DESC_F_NEXT
;
697 d
[1].addr
= (unsigned long)data
+ 1;
701 /* Second indirect */
702 d
[2].addr
= (unsigned long)data
+ 3;
707 d
[3].addr
= (unsigned long)data
+ 10;
709 d
[3].flags
= VRING_DESC_F_NEXT
;
711 d
[4].addr
= (unsigned long)data
+ 15;
713 d
[4].flags
= VRING_DESC_F_NEXT
;
715 d
[5].addr
= (unsigned long)data
+ 21;
719 /* Host picks it up (allocates new iov). */
720 vringh_iov_init(&riov
, host_riov
, ARRAY_SIZE(host_riov
));
721 vringh_iov_init(&wiov
, host_wiov
, ARRAY_SIZE(host_wiov
));
723 err
= vringh_getdesc_user(&vrh
, &riov
, &wiov
, getrange
, &head
);
725 errx(1, "vringh_getdesc_user: %i", err
);
728 errx(1, "vringh_getdesc_user: head %i not 0", head
);
730 assert(riov
.max_num
& VRINGH_IOV_ALLOCATED
);
731 if (getrange
!= getrange_slow
)
732 assert(riov
.used
== 7);
734 assert(riov
.used
== 28);
735 err
= vringh_iov_pull_user(&riov
, buf
, 29);
738 /* Data should be linear. */
739 for (i
= 0; i
< err
; i
++)
741 vringh_iov_cleanup(&riov
);
744 /* Don't leak memory... */
745 vring_del_virtqueue(vq
);
746 free(__user_addr_min
);