KVM VM Bring up with Open vSwitch Bridges

Step 1:

Install KVM

yum install qemu-kvm qemu-img virt-manager libvirt libvirt-python libvirt-client virt-install virt-viewer bridge-utils -y

Start Libvirtd:

systemctl start libvirtd
systemctl enable libvirtd
# lsmod | grep kvm
 kvm_intel 183621 0
 kvm 586948 1 kvm_intel
 irqbypass 13503 1 kvm

# virsh list
 Id Name State

Step 2:

Install Open vSwitch

yum install wget openssl-devel python-sphinx gcc make python-devel openssl-devel kernel-devel graphviz kernel-debug-devel autoconf automake rpm-build redhat-rpm-config libtool python-twisted-core python-zope-interface PyQt4 desktop-file-utils libcap-ng-devel groff checkpolicy selinux-policy-devel -y

Download the OVS package and Untar it:

mkdir -p ~/rpmbuild/SOURCES

wget http://openvswitch.org/releases/openvswitch-2.9.2.tar.gz

mv openvswitch-2.9.2.tar.gz rpmbuild/SOURCES/

cd ~/rpmbuild/SOURCES/

tar -xvzf openvswitch-2.9.2.tar.gz

rpmbuild -bb --nocheck openvswitch-2.9.2/rhel/openvswitch-fedora.spec

RPM install the OVS package

cd  ~/rpmbuild/RPMS

yum localinstall ~/rpmbuild/RPMS/x86_64/openvswitch-2.9.2-1.el7.x86_64.rpm -y

systemctl start openvswitch.service

systemctl enable openvswitch.service

systemctl status openvswitch.service

ovs-vsctl show

Add ports to the bridges

$ ovs-vsctl add-br br0
$ ovs-vsctl add-port br0 eno1

Step 3

Prep your images & xml files and Define/Start the VM using virsh.

Start by creating a “vm.xml” file as follows:

<domain type='kvm'>
 <boot dev='hd'/>
 <clock offset='utc'>
 <timer name='rtc' tickpolicy='catchup'/>
 <timer name='pit' tickpolicy='delay'/>
 <timer name='hpet' present='no'/>
 <disk type='file' device='disk'>
 <driver name='qemu' type='qcow2' cache='none'/>
 <source file='/home/image.qcow2' />
 <target dev='vda' bus='virtio'/>
 <interface type='bridge'>
 <source bridge='br0'/>
 <virtualport type='openvswitch'>
 <model type='virtio'/>
 <interface type='bridge'>
 <source bridge='br1'/>
 <virtualport type='openvswitch'>
 <model type='virtio'/>
 <serial type='pty'>
 <source path='/dev/pts/2'/>
 <target port='0'/>
 <alias name='serial0'/>
 <console type='pty' tty='/dev/pts/2'>
 <source path='/dev/pts/2'/>
 <target type='serial' port='0'/>
 <alias name='serial0'/>
 <input type='mouse' bus='ps2'/>
 <input type='keyboard' bus='ps2'/>
 <graphics type='vnc' port='5900' autoport='yes' listen=''>
 <listen type='address' address=''/>
 <model type='cirrus' vram='16384' heads='1'/>
 <alias name='video0'/>
 <memballoon model='virtio'>
 <alias name='balloon0'/>

Define the VM using above .xml file and start the VM.

$ virsh define vm.xml
$ virsh list --all
 Id    Name                           State
 1     BCF-CTRL-VM-02                

$ virsh start 1
$ virsh console 1 
(or use "virt-manager" for the gui version. You may have to relogin back with -X to forward xwindows to your system)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s