share memory between guest and nic
通过硬件的IOMMU,内核提供的共享内存、VFIO可以实现。
REF:
1. offical DPDK API Doc, 简书有翻译版 DPDK编程指南(翻译)(一) ( 二十七)
3. vhost-user 与其他的对比 virtio,vhost 和vhost-user
共享内存原理:
文件共享
qemu 与DPDK共享内存,是通过传递fd(fd是进程独享的,同一文件,两个进程间的fd可能不同)的方式实现的。所以实现fd传输是一个很麻烦的事。 参考这个例子,怎么实现fd传递的。
linux提供recvmsg与sendmsg来传递描述符,详见:
linux下进程间传递描述符(recvmsg与sendmsg)详解
进程间传递文件描述符--sendmsg,recvmsg, 传递过程有点magic, 其实是通过msghdr中的两个成员 msg_control 和 msg_controllen 辅助数据。(几个注意点)
Share fd: When you share a file descriptor over a socket, the kernel mediates. You need to prepare data using the cmsg(3)
macros, send it using sendmsg(2)
and receive it using recvmsg(2)
. The kernel is involved in the latter two operations, and it handles the conversion from a file descriptor to whatever data it needs to transmit the file descriptor, and making the file descriptor available in the receiving process.