docs: Update documentation vhost-user-net-testing.md

Updated the obsoleted instructions and scripts, based on Open vSwitch
v2.13.1, DPDK stable v19.11.3, and Cloud Hypervisor v15.0 (on Ubuntu
20.04.1).

Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
Bo Chen 2021-05-04 14:40:08 -07:00 committed by Sebastien Boeuf
parent b2b577257f
commit ac2469077f

View File

@ -1,27 +1,30 @@
# How to test Vhost-user net with OpenVSwitch/DPDK # How to test Vhost-user net with OpenVSwitch/DPDK
The purpose of this document is to illustrate how to test vhost-user-net in cloud-hypervisor with OVS/DPDK as the backend. The purpose of this document is to illustrate how to test vhost-user-net
in cloud-hypervisor with OVS/DPDK as the backend. This document was
tested with Open vSwitch v2.13.1, DPDK v19.11.3, and Cloud Hypervisor
v15.0 on Ubuntu 20.04.1 (host kernel v5.4.0).
## Framework ## Framework
It's a simple test to validate the communication between two virtual machine, connecting them to vhost-user ports respectively provided by `OVS/DPDK`. It's a simple test to validate the communication between two virtual machine, connecting them to vhost-user ports respectively provided by `OVS/DPDK`.
``` ```
+----+----------+ +-------------+-----------+-------------+ +----------+----+ +----+----------+ +-------------+-----------+-------------+ +----------+----+
| | | | | | | | | | | | | | | | | | | |
| |vhost-user|----------| vhost-user | ovs | vhost-user |----------|vhost-user| | | |vhost-user|----------| vhost-user | ovs | vhost-user |----------|vhost-user| |
| |net device| | port 1 | | port 2 | |net device| | | |net device| | port 1 | | port 2 | |net device| |
| | | | | | | | | | | | | | | | | | | |
| +----------+ +-------------+-----------+-------------+ +----------+ | | +----------+ +-------------+-----------+-------------+ +----------+ |
| | | | | | | | | | | |
|vm1 | | dpdk | | vm2 | |vm1 | | dpdk | | vm2 |
| | | | | | | | | | | |
+--+---------------------------------------------------------------------------------------------+--+ +--+---------------------------------------------------------------------------------------------+--+
| | hugepages | | | | hugepages | |
| +---------------------------------------------------------------------------------------------+ | | +---------------------------------------------------------------------------------------------+ |
| | | |
| host | | host |
| | | |
+---------------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------------+
``` ```
## Prerequisites ## Prerequisites
@ -30,44 +33,54 @@ Prior to running the test, the following steps need to be performed.
- Install DPDK - Install DPDK
- Install OVS - Install OVS
Here are some good references for detailing them. Here is a good reference for setting up OVS with DPDK from scratch:
- Red Hat https://docs.openvswitch.org/en/latest/intro/install/dpdk/.
* https://wiki.qemu.org/Documentation/vhost-user-ovs-dpdk
- Ubuntu server
* https://help.ubuntu.com/lts/serverguide/DPDK.html
* https://software.intel.com/en-us/articles/set-up-open-vswitch-with-dpdk-on-ubuntu-server
On Ubuntu systems (18.04 or newer), the OpenVswitch-DPDK package can be
easily installed with:
```bash
sudo apt-get update
sudo apt-get install openvswitch-switch-dpdk
sudo update-alternatives --set ovs-vswitchd /usr/lib/openvswitch-switch-dpdk/ovs-vswitchd-dpdk
```
## Test ## Test
The test runs with multiple queue (MQ) support enabled, using 2 pairs of TX/RX queues defined for both OVS and the virtual machine. Here are the details on how the test can be run. The test runs with multiple queue (MQ) support enabled, using 2 pairs of
TX/RX queues defined for both OVS and the virtual machine. Here are the
detailed instructions.
_Setup OVS_ _Setup OVS_
`ovs_test.sh` is created to setup and start OVS. OVS will provide the `dpdkvhostuser` backend running in server mode. Here is an example how to configure a basic OpenVswitch using DPDK:
```bash ```bash
mkdir -p /var/run/openvswitch # load the ovs kernel module
modprobe openvswitch modprobe openvswitch
killall ovsdb-server ovs-vswitchd sudo service openvswitch-switch start
rm -f /var/run/openvswitch/vhost-user* ovs-vsctl init
rm -f /etc/openvswitch/conf.db ovs-vsctl set Open_vSwitch . other_config:dpdk-init=true
export DB_SOCK=/var/run/openvswitch/db.sock # run on core 0-3 only
ovsdb-tool create /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema ovs-vsctl set Open_vSwitch . other_config:dpdk-lcore-mask=0xf
ovsdb-server --remote=punix:$DB_SOCK --remote=db:Open_vSwitch,Open_vSwitch,manager_options --pidfile --detach # allocate 2G huge pages (to NUMA 0 only)
ovs-vsctl --no-wait init ovs-vsctl set Open_vSwitch . other_config:dpdk-socket-mem=1024
ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-lcore-mask=0xf # run PMD (Pull Mode Driver) threads on core 0-3 only
ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-socket-mem=1024 ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0xf
ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true sudo service openvswitch-switch restart
ovs-vsctl --no-wait set Open_vSwitch . other_config:pmd-cpu-mask=0xf # double check the configurations
ovs-vswitchd unix:$DB_SOCK --pidfile --detach --log-file=/var/log/openvswitch/ovs-vswitchd.log ovs-vsctl list Open_vSwitch
```
Here is an example how to create a bridge and add two DPDK ports to it
(for later use via Cloud Hypervisor):
```bash
# create a bridge
ovs-vsctl add-br ovsbr0 -- set bridge ovsbr0 datapath_type=netdev ovs-vsctl add-br ovsbr0 -- set bridge ovsbr0 datapath_type=netdev
# create two DPDK ports and add them to the bridge
ovs-vsctl add-port ovsbr0 vhost-user1 -- set Interface vhost-user1 type=dpdkvhostuser ovs-vsctl add-port ovsbr0 vhost-user1 -- set Interface vhost-user1 type=dpdkvhostuser
ovs-vsctl add-port ovsbr0 vhost-user2 -- set Interface vhost-user2 type=dpdkvhostuser ovs-vsctl add-port ovsbr0 vhost-user2 -- set Interface vhost-user2
type=dpdkvhostuser
# set the number of rx queues
ovs-vsctl set Interface vhost-user1 options:n_rxq=2 ovs-vsctl set Interface vhost-user1 options:n_rxq=2
ovs-vsctl set Interface vhost-user2 options:n_rxq=2 ovs-vsctl set Interface vhost-user2 options:n_rxq=2
``` ```
_Run ovs_test.sh_
```bash
./ovs_test.sh
```
_Launch the VMs_ _Launch the VMs_
@ -89,19 +102,21 @@ VMs run in client mode. They connect to the socket created by the `dpdkvhostuser
--kernel vmlinux \ --kernel vmlinux \
--cmdline "console=ttyS0 console=hvc0 root=/dev/vda1 rw" \ --cmdline "console=ttyS0 console=hvc0 root=/dev/vda1 rw" \
--disk path=focal-server-cloudimg-amd64.raw \ --disk path=focal-server-cloudimg-amd64.raw \
--net "mac=52:54:20:11:C5:02,vhost_user=true,socket=/var/run/openvswitch/vhost-user2,num_queues=4" --net mac=52:54:20:11:C5:02,vhost_user=true,socket=/var/run/openvswitch/vhost-user2,num_queues=4
``` ```
_Setup VM1_ _Setup VM1_
```bash ```bash
# From inside the guest # From inside the guest
sudo ip addr add 172.100.0.1/24 dev enp0s3 sudo ip addr add 172.100.0.1/24 dev ens2
sudo ip link set up dev ens2
``` ```
_Setup VM2_ _Setup VM2_
```bash ```bash
# From inside the guest # From inside the guest
sudo ip addr add 172.100.0.2/24 dev enp0s3 sudo ip addr add 172.100.0.2/24 dev ens2
sudo ip link set up dev ens2
``` ```
_Ping VM1 from VM2_ _Ping VM1 from VM2_
@ -129,4 +144,3 @@ _Run VM2 as client_
# From inside the guest # From inside the guest
iperf3 -c 172.100.0.1 -t 30 -p 4444 & iperf3 -c 172.100.0.1 -t 30 -p 4444 &
``` ```