-This section lists prerequisite packages that must be installed.
-
-Installing Packages on the Host(vhost cuse required)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-The vhost cuse code uses the following packages; fuse, fuse-devel, and kernel-modules-extra.
-The vhost user code don't rely on those modules as eventfds are already installed into vhost process through
-Unix domain socket.
-
-#. Install Fuse Development Libraries and headers:
-
- .. code-block:: console
-
- yum -y install fuse fuse-devel
-
-#. Install the Cuse Kernel Module:
-
- .. code-block:: console
-
- yum -y install kernel-modules-extra
-
-QEMU simulator
-~~~~~~~~~~~~~~
-
-For vhost user, qemu 2.2 is required.
-
-Setting up the Execution Environment
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-The vhost sample code requires that QEMU allocates a VM's memory on the hugetlbfs file system.
-As the vhost sample code requires hugepages,
-the best practice is to partition the system into separate hugepage mount points for the VMs and the vhost sample code.
-
-.. note::
-
- This is best-practice only and is not mandatory.
- For systems that only support 2 MB page sizes,
- both QEMU and vhost sample code can use the same hugetlbfs mount point without issue.
-
-**QEMU**
-
-VMs with gigabytes of memory can benefit from having QEMU allocate their memory from 1 GB huge pages.
-1 GB huge pages must be allocated at boot time by passing kernel parameters through the grub boot loader.
-
-#. Calculate the maximum memory usage of all VMs to be run on the system.
- Then, round this value up to the nearest Gigabyte the execution environment will require.
-
-#. Edit the /etc/default/grub file, and add the following to the GRUB_CMDLINE_LINUX entry:
-
- .. code-block:: console
-
- GRUB_CMDLINE_LINUX="... hugepagesz=1G hugepages=<Number of hugepages required> default_hugepagesz=1G"
-
-#. Update the grub boot loader:
-
- .. code-block:: console
-
- grub2-mkconfig -o /boot/grub2/grub.cfg
-
-#. Reboot the system.
-
-#. The hugetlbfs mount point (/dev/hugepages) should now default to allocating gigabyte pages.
-
-.. note::
-
- Making the above modification will change the system default hugepage size to 1 GB for all applications.
-
-**Vhost Sample Code**
-
-In this section, we create a second hugetlbs mount point to allocate hugepages for the DPDK vhost sample code.
-
-#. Allocate sufficient 2 MB pages for the DPDK vhost sample code:
-
- .. code-block:: console
-
- echo 256 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
-
-#. Mount hugetlbs at a separate mount point for 2 MB pages:
-
- .. code-block:: console
-
- mount -t hugetlbfs nodev /mnt/huge -o pagesize=2M
-
-The above steps can be automated by doing the following:
-
-#. Edit /etc/fstab to add an entry to automatically mount the second hugetlbfs mount point:
-
- ::
-
- hugetlbfs <tab> /mnt/huge <tab> hugetlbfs defaults,pagesize=1G 0 0
-
-#. Edit the /etc/default/grub file, and add the following to the GRUB_CMDLINE_LINUX entry:
-
- ::
-
- GRUB_CMDLINE_LINUX="... hugepagesz=2M hugepages=256 ... default_hugepagesz=1G"
-
-#. Update the grub bootloader:
-
- .. code-block:: console
-
- grub2-mkconfig -o /boot/grub2/grub.cfg
-
-#. Reboot the system.
-
-.. note::
-
- Ensure that the default hugepage size after this setup is 1 GB.
-
-Setting up the Guest Execution Environment
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-It is recommended for testing purposes that the DPDK testpmd sample application is used in the guest to forward packets,
-the reasons for this are discussed in Section 22.7, "Running the Virtual Machine (QEMU)".
-
-The testpmd application forwards packets between pairs of Ethernet devices,
-it requires an even number of Ethernet devices (virtio or otherwise) to execute.
-It is therefore recommended to create multiples of two virtio-net devices for each Virtual Machine either through libvirt or
-at the command line as follows.
-
-.. note::
-
- Observe that in the example, "-device" and "-netdev" are repeated for two virtio-net devices.
-
-For vhost cuse:
-
-.. code-block:: console
-
- user@target:~$ qemu-system-x86_64 ... \
- -netdev tap,id=hostnet1,vhost=on,vhostfd=<open fd> \
- -device virtio-net-pci, netdev=hostnet1,id=net1 \
- -netdev tap,id=hostnet2,vhost=on,vhostfd=<open fd> \
- -device virtio-net-pci, netdev=hostnet2,id=net1
-
-For vhost user:
-
-.. code-block:: console
-
- user@target:~$ qemu-system-x86_64 ... \
- -chardev socket,id=char1,path=<sock_path> \
- -netdev type=vhost-user,id=hostnet1,chardev=char1 \
- -device virtio-net-pci,netdev=hostnet1,id=net1 \
- -chardev socket,id=char2,path=<sock_path> \
- -netdev type=vhost-user,id=hostnet2,chardev=char2 \
- -device virtio-net-pci,netdev=hostnet2,id=net2
-
-sock_path is the path for the socket file created by vhost.
-
-Compiling the Sample Code
--------------------------
-#. Compile vhost lib:
-
- To enable vhost, turn on vhost library in the configure file config/common_linuxapp.
-
- .. code-block:: console
-
- CONFIG_RTE_LIBRTE_VHOST=n
-
- vhost user is turned on by default in the configure file config/common_linuxapp.
- To enable vhost cuse, disable vhost user.
-
- .. code-block:: console
-
- CONFIG_RTE_LIBRTE_VHOST_USER=y
-
- After vhost is enabled and the implementation is selected, build the vhost library.
-
-#. Go to the examples directory:
-
- .. code-block:: console
-
- export RTE_SDK=/path/to/rte_sdk
- cd ${RTE_SDK}/examples/vhost
-
-#. Set the target (a default target is used if not specified). For example:
-
- .. code-block:: console
-
- export RTE_TARGET=x86_64-native-linuxapp-gcc
-
- See the DPDK Getting Started Guide for possible RTE_TARGET values.
-
-#. Build the application:
-
- .. code-block:: console
-
- cd ${RTE_SDK}
- make config ${RTE_TARGET}
- make install ${RTE_TARGET}
- cd ${RTE_SDK}/examples/vhost
- make
-
-#. Go to the eventfd_link directory(vhost cuse required):
-
- .. code-block:: console
-
- cd ${RTE_SDK}/lib/librte_vhost/eventfd_link
-
-#. Build the eventfd_link kernel module(vhost cuse required):
-
- .. code-block:: console
-
- make
-
-Running the Sample Code
------------------------
-
-#. Install the cuse kernel module(vhost cuse required):
-
- .. code-block:: console
-
- modprobe cuse
-
-#. Go to the eventfd_link directory(vhost cuse required):
-
- .. code-block:: console
-
- export RTE_SDK=/path/to/rte_sdk
- cd ${RTE_SDK}/lib/librte_vhost/eventfd_link
-
-#. Install the eventfd_link module(vhost cuse required):
-
- .. code-block:: console
-
- insmod ./eventfd_link.ko
-
-#. Go to the examples directory:
-
- .. code-block:: console