Free Hosting Online for WorkStations

< Previous | Contents | Next >

5.6. OpenVswitch DPDK to KVM Guests


If you are not building some sort of SDN switch or NFV on top of DPDK it is very likely that you want to forward traffic to KVM guests. The good news is, that with the new qemu/libvirt/dpdk/openvswitch versions in Ubuntu 16.04 this is no more about manually appending commandline string. This chapter covers a basic configuration how to connect a KVM guest to a OpenVswitch-DPDK instance.


The Guest has to be backed by shared hugepages for DPDK/vhost_user to work. To ensure in general that libvirt/qemu-kvm finds a proper hugepage mountpoint you can just enable KVM_HUGEPAGES in /etc/ default/qemu-kvm. Afterwards restart the service to pick up the changed configuration.


sed -ri -e 's,(KVM_HUGEPAGES=).*,\11,' /etc/default/qemu-kvm service qemu-kvm restart


To let a guest be backed by hugepages is now also supported via recent libvirt, just add the following snippet to your virsh xml (or the equivalent libvirt interface you use). Those xmls can also be used as templates to easily spawn guests with "uvt-kvm create".


<numa>

<cell id='0' cpus='0' memory='6291456' unit='KiB' memAccess='shared'/>

</numa> [...]

<memoryBacking>

<hugepages>

<page size="2" unit="M" nodeset="0"/>

</hugepages>

</memoryBacking>


The new and recommended way to get to a KVM guest is using vhost_user. This will cause DPDK to create a socket that qemu will connect the guest to. Here an example how to add such a port to the bridge you created (see above).


ovs-vsctl add-port ovsdpdkbr0 vhost-user-1 -- set Interface vhost-user-1 type=dpdkvhostuser


This will create a vhost_user socket at /var/run/openvswitch/vhost-user-1


To let libvirt/kvm consume this socket and create a guest virtio network device for it add a snippet like this to your guest definition as the network definition.


<interface type='vhostuser'>

<source type='unix' path='/var/run/openvswitch/vhost-user-1' mode='client'/>

<model type='virtio'/>

</interface>


Top OS Cloud Computing at OnWorks: