libvirt + openvswitch + ubuntu 24.04
Abstract
This document will show how to configure libvirt with openvswitch so that VMs could use openvswitch directly. This is useful if the openvswitch has a trunk connection with your switch that carries multiple VLANs.
Requirements
You need the following
- Ubuntu 24.04
- cockpit - can access VM through web
- openssh-server
- qemu-kvm
- libvirt-daemon-system
- cockpit-machines
Setup
Must have dedicated physical port which is linked to your switch. We will be using `eno1` here.
Create openvswitch bridge
$ ovs-vsctl add-br br0# add physical interface$ ovs-vsctl add-port br0 eno1# showing$ ovs-vsctl show
Bridge br0
Port br0
Interface br0
type: internal
Port eno1
Interface eno1
ovs_version: "3.3.0"
Create a br0 for virsh net
$ cat libvirt-br0-simple.xml<network><name>br0</name><forward mode='bridge'/><bridge name='br0'/><virtualport type='openvswitch'/></network>
Adding portgroup with vlans live
virsh net-update ovs-network add --section portgroup --xml "<portgroup name='trunk'><vlan trunk='yes'><tag id='2'/><tag id='3'/></vlan></portgroup>" --config --live
Bring the link up
ip link set br0 upip link set eno1 up
When creating a network through the cockpit, before running make sure to edit the xml using virst edit, and modify <source
<interface type='network'>
<mac address='52:54:00:ca:f6:27'/>
<source network='br0' portgroup='main'/>
References
- https://www.redhat.com/en/blog/libvirt-open-vswitch
- https://documentation.ubuntu.com/server/how-to/virtualisation/libvirt/
Comments
Post a Comment