OVS DPDK in Docker - MirgDenis/scripts GitHub Wiki
Creation date October 2020
Following instruction works for OVS 2.11 DPDK 18.11.5, due to this patch https://patches.dpdk.org/patch/60354/ is is impossible to run OVS 2.11 with DPDK 18.11.6
To run OVS-DPD in container:
- Add vfio-pci module
modprobe vfio enable_unsafe_noiommu_mode=1
modprobe vfio-pci
- Add hugepages
sysctl -w vm.nr_hugepages=512
- Build Dockerimage
https://opendev.org/openstack/openstack-helm-images/src/branch/master/openvswitch/Dockerfile.ubuntu_bionic-dpdk
- Create run script.
Note: init script can become obsolete, as well as Dockerfile mentioned above.
#!/bin/bash
mkdir -p /var/run/openvswitch/vhostuser
mkdir -p /etc/openvswitch
mkdir -p /run/openvswitch
export DB_SOCK=/var/run/openvswitch/db.sock
export DB_CONF=/etc/openvswitch/conf.db
export PID_D=/run/openvswitch/ovs-vswitchd.pid
export PID_S=/run/openvswitch/ovsdp-server.pid
ovsdb-tool create $DB_CONF
ovsdb-server $DB_CONF --remote=punix:$DB_SOCK \
--remote=db:Open_vSwitch,Open_vSwitch,manager_options \
--private-key=db:Open_vSwitch,SSL,private_key \
--certificate=Open_vSwitch,SSL,certificate \
--bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \
--pidfile=$PID_S \
--detach
ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-hugepage-dir=/mnt/huge
ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-socket-mem=512
ovs-vsctl --no-wait set Open_vSwitch . other_config:vhost-sock-dir=vhostuser
ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true
ovs-vswitchd unix:$DB_SOCK --pidfile=$PID_D
- Run container
docker run -it --rm --privileged --network host -v /dev/hugepages:/mnt/huge -v /tmp:/tmp -v /dev/vfio:/dev/vfio --name dpdk <image> bash
- Start OVSDB and OVS
bash -x /tmp/run.sh
- Enter container in other console
docker exec -it dpdk bash
- Unbind/Bind interface. Do not use interface with SSH session!!!
dpdk-devbind.py -u <PCI_ID>
dpdk-devbind.py -b vfio-pci <PCI_ID>
dpdk-devbind.py -s
- Create bridge and port
ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev
ovs-vsctl add-port br0 dpdk0 -- set Interface dpdk0 type=dpdk options:dpdk-devargs=<PCI_ID>
https://www.redhat.com/en/blog/hands-vhost-user-warm-welcome-dpdk
https://doc.dpdk.org/guides-18.11/nics/virtio.html