In May 2011, I read a request for installation Openvswitch on Qemu image. I started to play with Openvswitch and finally became fan of this project. I soon realized how powerful can be Openvswitch, offering many features so far available only in hardware switches.

After several days spent with playing with Core Linux and Openvswitch I was able to create Core Qemu image with 8021q support and install Openvswitch on the top of it. The reason why I chose Core Linux is that I am familiar with this minimal Linux distribution and the size of Core Qemu appliance is incredibly small.

The tutorial describes step-by-step installation of Openvswitch on Qemu image. It also explains how to create Openvswitch extension and make it ready for submitting to Tinycore public repository. Installation of Core Linux on Qemu image is not shown but you can find it here. Similarly Qemu compilation and installation on Fedora Linux is explained here.

I also created three labs using Openvswitch. I tested how can Openvswitch works with VLANs, 802.1q trunk ports and if it is capable of creating L3 VLAN interfaces. All labs are available here:

1. Start Qemu Core VM

Assuming your Core Qemu image with console support has been created and supports 8021q VLAN tagging start the image with the commad:

To compile openvswitch with the ovsdmonitor tool, the machine must also have the following extensions installed. However it is very likely that the extensions are not available in recent tinycore repository.

If you are not sure with required applications needed for building Openvswitch, please read the installation manual.

Now we can run a script that prepares kernel sources for Core Linux. The script downloads patched Linux kernel and kernel config file from tinycore repository, installs extensions required for building kernel sources and build kernel sources.

$ /usr/local/bin/linux-kernel-sources-env.sh

4. Openvswitch Installation

First, we should read how manual describing process of creating extensions for Core Linux. Then we can set compiler flags.

After building, a kernel module "openvswitch.ko" is saved in a ./datapath/linux/ directory. We will use this kernel module as performance is better when a kernel module is loaded. Create a directory in a structure of the openvswitch extension where the kernel module openvswitch.ko will be saved.

Check if module openvswitch.ko is loaded to the kernel with lsmod command.

lsmod | grep openvswitch
openvswitch 49152 0

6. Backup Vswitch.ovsschema

In order to initialize the configuration database using ovsdb-tool, a file vswitch.ovsschema is needed. We must to copy it to /tmp/openvswitch-$(uname -r)/usr/local/etc/openvswitch/vswitchd/ to include it to the extension.

An info file describing its contents (.tcz.info) - this content is standardized. Check repository for examples.

f) Create openvswitch build dependency file

Additional build instructions in a plain text file for future reference, mentioning such things as which extensions are required to build the package and what compile flags were used. We do not have to attach this file together with files sent with submitted openswitch extension.

g) Create the dependency list for openvswitch extension

List of the extensions that have to be presented to run openvswitch extension correctly.

Copy Openvswitch files we have created in steps 1-7 (.tcz, .list, .md5.txt, .info, .dep) from Qemu image that we have used for Openvswitch installation to Qemu image with Core Linux with no extension installed to the directory /tmp/All.

$ mkdir /tmp/All
$ cd /tmp/All

$ scp -rv brezular@10.0.2.2:/home/brezular/openvswitch/* .

Run a script for testing extensions:

sudo submitqc5

The script checks all openvswitch files in /tmp/All and creates the directory /tmp/submitqc/ containing the log files.

sudo ovsdb-tool create /usr/local/etc/openvswitch/conf.db /usr/local/etc/openvswitch/vswitchd/vswitch.ovsschema
ovsdb-tool: failed to read schema: "/usr/local/etc/openvswitch/vswitchd/vswitch.ovsschema" could not be read as JSON (error opening "/usr/local/etc/openvswitch/vswitchd/vswitch.ovsschema": No such file or directory)

Note: If you installed openvswitch from Microcore repository (tce -wi openvswitch), file /usr/local/etc/openvswitch/vswitchd/vswitch.ovsschema should have been automatically created during an installation of openvswitch extension. In this case you have probably got a problem with permissions. Can you first switch to root account with "sudo su" command and then try to create database again with "ovsdb-tool create /usr/local/etc/openvswitch/conf.db /usr/local/etc/openvswitch/vswitchd/vswitch.ovsschema" command.