Installing Open vSwitch with KVM

Installing Open vSwitch with KVM

Installing Open vSwitch with KVM

This tutorial is for installing Open vSwitch with KVM in order to replace traditional hypervisor Ethernet switching using Linux bridging with Open vSwitch.


Installing Open vSwitch on Ubuntu with KVM

I rebuilt this box becuase as fun as it was to setup OpenStack (I think) there are a million modules that would take more time to clip out rather than just rebuilding. Anyone gotten Nova integrated into Open vSwitch yet? That will be a great marriage for nailing up cloud nodes through tunnels dynamically. I expect Open vSwitch to be an important not just to Vmware moving forward with software defined networking but more importantly setting a trend for open source software (OSS) project in networking.

Pulled some deps for some other things but here is history.

sudo apt-get install python-simplejson python-qt4 python-zopeinterface python-twisted-conch automake autoconf gcc kvm uml-utilities virt-manager qemu-kvm kvm-pxe uml-utilities

Basically just my bash history.

./ (apt-get install libtool will fix autoconf errors)
./configure --with-linux=/lib/modules/uname -r/build
make install
insmod datapath/linux/openvswitch.ko

Check for loaded ovs module

lsmod | grep open
lsmod | grep bridge
rmmod bridge
mkdir -p /usr/local/etc/openvswitch

Start OpenvSwitch

ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
ovsdb-server /usr/local/etc/openvswitch/conf.db --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,manager_options --private-key=db:SSL,private_key --certificate=db:SSL,certificate --bootstrap-ca-cert=db:SSL,ca_cert --pidfile --detach -log--files
ovs-vsctl --no-wait init
ovs-vswitchd --pidfile --log-file --detach -v

Configure a bridge and add eth0 to the new bridge. Think locally significant Vlans.

sudo ovs-vsctl add-br br0
ovs-vsctl add-port br0 eth0
ovs-vsctl list port

Change your eth0 IP to your new br0 interface.

ifconfig eth0 0
ifconfig br0 x.x.x.x netmask
route add default gw br0

Outside interface is now your br0.

These two scripts bring up the KVM Tap interfaces into your
bridge from the CLI.

$ cat /etc/ovs-ifup
/sbin/ifconfig $1 up
ovs-vsctl add-port ${switch} $1
$ cat /etc/ovs-ifdown 
/sbin/ifconfig $1 down
ovs-vsctl del-port ${switch} $1
#Then make executable
chmod +x /etc/ovs-ifup /etc/ovs-ifdown

Here are some KVM examples. Starting with the CD is easiest.
No build needed for testing.


kvm -m 1024 -hda /media/Storage/imgs/centos.kvm -net nic,macaddr=00:11:22:CC:CC:C5 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown &

OS Install

kvm -m 512 -hda /media/Storage/imgs/centos.kvm -net nic,macaddr=00:11:22:CC:CC:C5 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -cdrom /media/Storage/vm-images/CentOS-6.2-x86_64-LiveCD.iso &

CD Boot

kvm -m 512 -net nic,macaddr=00:11:22:CC:CC:10 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -cdrom /HD/Storage/vm-images/ubuntu-11.10-desktop-amd64.iso &

Make an Image from CD

qemu-img create -f qcow2 /media/Storage/imgs/uCentOS-6.2.img 6G

Somewhere a VM if broken on the spinup will still allocate a tap.

Installing Open vSwitch with KVM Errors

If you get this kvm: -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown: Device ‘tap’ could not be initialized
Just delete the tap0. Need to dig into a work around cleaner than scripts.
ovs-vsctl del-port tap0

Thanks for stopping by