KVM OVS UEL 14.04

Building KVM on Flash with OpenvSwitch SDN on Ubuntu 14.04.1 Desktop

This wiki details how to build KVM virtual guests on flash using OpenvSwitch for the networking, rather than the default libvirt networking. In addition, this wiki also shows how to use virtio-blk-data-plane in your KVM guest to obtain the performance benefit of world-record-setting benchmark IOPS in a KVM guest. Last, but not least, this wiki shows how to use the "logical_block_size" and "physical_block_size" parameters in your KVM guest XML file to configure your KVM guest for use with high-speed flash storage by setting the relevant block sizes to 512 or 4096 as required.

In particular, most material found on the internet as of the time of writing this wiki describe attaching eth0 directly to the OpenvSwitch, which, while feasible for Ubuntu 14.04.1 server, is not as feasible when using Ubuntu 14.04.1 Desktop, in a testing type environment, due to the fact that the Desktop version uses the Network-Manager applet and package which is known to not play well in certain operations with OpenvSwitch.

This wiki describes a method which creates an OpenvSwitch, assigns an IP range to the switch, and uses dhcp to deliver ip addresses to KVM guests attached to the switch, all without touching or affecting the function of network-manager. Internet connectivity for the KVM guests is provided by iptables rules so that physical interfaces on the KVM host need not be directly attached to the OpenvSwitch. This wiki also details how to implement virtio-blk-data-plane for very high bandwidth and IOPS performance in the kvm guest as described by Stefan Hajnoczi at his blog here.

Additional information about virtio-blk-data-plane and it's advantages and some of the world record benchmarks it holds for highest IOPS in a single VM guest can be found here and here and here.

The wiki hopes to persuade readers of numerous advantages to other virtualization solutions with respect to the fact that KVM is arguably the best choice when running virtual guests on flash storage because it can leverage the high-speed of flash better than other virtualization solutions.

While I hope that some production users of KVM will get some useful ideas from at least portions of this wiki, I want to say that this wiki is primarily intended to accomplish two things:

  1. To provide a simple and detailed cookbook for using your laptop or desktop machine as a KVM / OpenvSwitch lab; and

  2. To showcase the power and simplicity of KVM and OpenvSwitch and hopefully persuade for the adoption of both in enterprise.

Installing OpenvSwitch and KVM on Ubuntu 14.04.1

OpenvSwitch and KVM are installed from the apt-get repositories in this wiki as shown below. OpenvSwitch and KVM can also be installed from source for those who want the most recent version. These repository versions for Ubuntu 14.04.1 have all the features needed. Before installing KVM you need to verify that your system hardware will support KVM using the methods described here Some of those methods are shown below.

gstanden@vmem:~$ egrep -c '(vmx|svm)' /proc/cpuinfo

If value is "0" it means that your CP doesn't support hardware virtualization. If 1 or more it does - but you still need to make sure that virtualization is enabled in the BIOS.For example on my Lenovo W520 Mobile Workstation the result is as shown below.

gstanden@vmem:~$ egrep -c '(vmx|svm)' /proc/cpuinfo 8

Another test is as shown below.

gstanden@vmem2:~$ kvm-ok

The program 'kvm-ok' is currently not installed. You can install it by typing:

sudo apt-get install cpu-checker

gstanden@vmem2:~$

gstanden@vmem2:~$ sudo apt-get install cpu-checker

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following extra packages will be installed:

msr-tools

The following NEW packages will be installed:

cpu-checker msr-tools

0 upgraded, 2 newly installed, 0 to remove and 116 not upgraded.

Need to get 17.5 kB of archives.

After this operation, 112 kB of additional disk space will be used.

Do you want to continue? [Y/n] Y

Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main msr-tools amd64 1.3-2 [10.6 kB]

Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main cpu-checker amd64 0.7-0ubuntu4 [6,834 B]

Fetched 17.5 kB in 0s (60.4 kB/s)

Selecting previously unselected package msr-tools.

(Reading database ... 194786 files and directories currently installed.)

Preparing to unpack .../msr-tools_1.3-2_amd64.deb ...

Unpacking msr-tools (1.3-2) ...

Selecting previously unselected package cpu-checker.

Preparing to unpack .../cpu-checker_0.7-0ubuntu4_amd64.deb ...

Unpacking cpu-checker (0.7-0ubuntu4) ...

Processing triggers for man-db (2.6.7.1-1) ...

Setting up msr-tools (1.3-2) ...

Setting up cpu-checker (0.7-0ubuntu4) ...

gstanden@vmem2:~$

gstanden@vmem2:~$ sudo kvm-ok

INFO: /dev/kvm does not exist

HINT: sudo modprobe kvm_intel

INFO: Your CPU supports KVM extensions

INFO: KVM (vmx) is disabled by your BIOS

HINT: Enter your BIOS setup and enable Virtualization Technology (VT),

and then hard poweroff/poweron your system

KVM acceleration can NOT be used

gstanden@vmem2:~$

INFO: /dev/kvm exists KVM acceleration can be used

Reboot, and go into BIOS and enable virtualization extensions.

gstanden@vmem2:~$ sudo kvm-ok

[sudo] password for gstanden:

INFO: /dev/kvm exists

KVM acceleration can be used

gstanden@vmem2:~$

Next install OpenvSwitch and KVM from repositories as shown below.

gstanden@vmem2:~$ sudo apt-get install openvswitch-switch qemu-kvm libvirt-bin virt-manager | tee log1

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following extra packages will be installed:

augeas-lenses bridge-utils cgroup-lite ebtables gawk ipxe-qemu libaio1

libappindicator1 libaugeas0 libbonobo2-0 libbonobo2-common libbonoboui2-0

libbonoboui2-common libboost-thread1.54.0 libfdt1 libglade2-0 libgnome2-0

libgnome2-bin libgnome2-common libgnomecanvas2-0 libgnomecanvas2-common

libgnomeui-0 libgnomeui-common libgnomevfs2-0 libgnomevfs2-common

libgtk-vnc-1.0-0 libgvnc-1.0-0 libidl-common libidl0 libindicator7 libnetcf1

liborbit-2-0 liborbit2 librados2 librbd1 libsdl1.2debian libseccomp2

libsigsegv2 libusbredirparser1 libvirt0 libvte-common libvte9 libxen-4.4

libxenstore3.0 libxml2-utils openvswitch-common python-appindicator

python-glade2 python-gnome2 python-gtk-vnc python-libvirt python-pyorbit

python-urlgrabber python-vte qemu-keymaps qemu-system-common qemu-system-x86

qemu-utils seabios sharutils virtinst

Suggested packages:

augeas-doc gawk-doc augeas-tools libbonobo2-bin desktop-base

libgnomevfs2-bin libgnomevfs2-extra gamin fam gnome-mime-data radvd lvm2

openvswitch-datapath-module python-gtk2-doc python-gnome2-doc

python-pyorbit-dbg samba vde2 sgabios debootstrap bsd-mailx mailx

virt-viewer python-guestfs python-spice-client-gtk

The following NEW packages will be installed:

augeas-lenses bridge-utils cgroup-lite ebtables gawk ipxe-qemu libaio1

libappindicator1 libaugeas0 libbonobo2-0 libbonobo2-common libbonoboui2-0

libbonoboui2-common libboost-thread1.54.0 libfdt1 libglade2-0 libgnome2-0

libgnome2-bin libgnome2-common libgnomecanvas2-0 libgnomecanvas2-common

libgnomeui-0 libgnomeui-common libgnomevfs2-0 libgnomevfs2-common

libgtk-vnc-1.0-0 libgvnc-1.0-0 libidl-common libidl0 libindicator7 libnetcf1

liborbit-2-0 liborbit2 librados2 librbd1 libsdl1.2debian libseccomp2

libsigsegv2 libusbredirparser1 libvirt-bin libvirt0 libvte-common libvte9

libxen-4.4 libxenstore3.0 libxml2-utils openvswitch-common

openvswitch-switch python-appindicator python-glade2 python-gnome2

python-gtk-vnc python-libvirt python-pyorbit python-urlgrabber python-vte

qemu-keymaps qemu-kvm qemu-system-common qemu-system-x86 qemu-utils seabios

sharutils virt-manager virtinst

0 upgraded, 65 newly installed, 0 to remove and 116 not upgraded.

Need to get 13.8 MB of archives.

After this operation, 72.7 MB of additional disk space will be used.

Do you want to continue? [Y/n] Y

Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main libsigsegv2 amd64 2.10-2 [15.0 kB]

Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main gawk amd64 1:4.0.1+dfsg-2.1ubuntu2 [781 kB]

Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6,364 B]

Get:4 http://us.archive.ubuntu.com/ubuntu/ trusty/main libindicator7 amd64 12.10.2+14.04.20140402-0ubuntu1 [21.9 kB]

Get:5 http://us.archive.ubuntu.com/ubuntu/ trusty/main libappindicator1 amd64 12.10.1+13.10.20130920-0ubuntu4 [18.2 kB]

Get:6 http://us.archive.ubuntu.com/ubuntu/ trusty/main libbonobo2-common all 2.32.1-0ubuntu5 [34.2 kB]

Get:7 http://us.archive.ubuntu.com/ubuntu/ trusty/main libidl-common all 0.8.14-0.2ubuntu4 [8,196 B]

Get:8 http://us.archive.ubuntu.com/ubuntu/ trusty/main libidl0 amd64 0.8.14-0.2ubuntu4 [65.9 kB]

Get:9 http://us.archive.ubuntu.com/ubuntu/ trusty/main liborbit-2-0 amd64 1:2.14.19-0.3 [138 kB]

Get:10 http://us.archive.ubuntu.com/ubuntu/ trusty/main liborbit2 amd64 1:2.14.19-0.3 [14.7 kB]

Get:11 http://us.archive.ubuntu.com/ubuntu/ trusty/main libbonobo2-0 amd64 2.32.1-0ubuntu5 [214 kB]

Get:12 http://us.archive.ubuntu.com/ubuntu/ trusty/main libglade2-0 amd64 1:2.6.4-2 [44.6 kB]

Get:13 http://us.archive.ubuntu.com/ubuntu/ trusty/main libgnomevfs2-common amd64 1:2.24.4-1ubuntu6 [22.8 kB]

Get:14 http://us.archive.ubuntu.com/ubuntu/ trusty/main libgnomevfs2-0 amd64 1:2.24.4-1ubuntu6 [210 kB]

Get:15 http://us.archive.ubuntu.com/ubuntu/ trusty/main libgnome2-common all 2.32.1-4ubuntu1 [33.3 kB]

Get:16 http://us.archive.ubuntu.com/ubuntu/ trusty/main libgnome2-bin amd64 2.32.1-4ubuntu1 [15.0 kB]

Get:17 http://us.archive.ubuntu.com/ubuntu/ trusty/main libgnome2-0 amd64 2.32.1-4ubuntu1 [43.2 kB]

Get:18 http://us.archive.ubuntu.com/ubuntu/ trusty/main libgnomecanvas2-common all 2.30.3-2 [9,080 B]

Get:19 http://us.archive.ubuntu.com/ubuntu/ trusty/main libgnomecanvas2-0 amd64 2.30.3-2 [82.7 kB]

Get:20 http://us.archive.ubuntu.com/ubuntu/ trusty/main libbonoboui2-common all 2.24.5-0ubuntu3 [11.4 kB]

Get:21 http://us.archive.ubuntu.com/ubuntu/ trusty/main libbonoboui2-0 amd64 2.24.5-0ubuntu3 [151 kB]

Get:22 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libboost-thread1.54.0 amd64 1.54.0-4ubuntu3.1 [26.5 kB]

Get:23 http://us.archive.ubuntu.com/ubuntu/ trusty/main libgnomeui-common all 2.24.5-3 [16.5 kB]

Get:24 http://us.archive.ubuntu.com/ubuntu/ trusty/main libgnomeui-0 amd64 2.24.5-3 [203 kB]

Get:25 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main librados2 amd64 0.80.5-0ubuntu0.14.04.1 [1,407 kB]

Get:26 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main librbd1 amd64 0.80.5-0ubuntu0.14.04.1 [316 kB]

Get:27 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libsdl1.2debian amd64 1.2.15-8ubuntu1.1 [162 kB]

Get:28 http://us.archive.ubuntu.com/ubuntu/ trusty/main libseccomp2 amd64 2.1.0+dfsg-1 [34.8 kB]

Get:29 http://us.archive.ubuntu.com/ubuntu/ trusty/main libusbredirparser1 amd64 0.6-2ubuntu1 [13.2 kB]

Get:30 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main qemu-system-common amd64 2.0.0+dfsg-2ubuntu1.3 [158 kB]

Get:31 http://us.archive.ubuntu.com/ubuntu/ trusty/main libfdt1 amd64 1.4.0+dfsg-1 [15.7 kB]

Get:32 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main augeas-lenses all 1.2.0-0ubuntu1.1 [230 kB]

Get:33 http://us.archive.ubuntu.com/ubuntu/ trusty/main bridge-utils amd64 1.5-6ubuntu2 [29.2 kB]

Get:34 http://us.archive.ubuntu.com/ubuntu/ trusty/main ebtables amd64 2.0.10.4-3ubuntu1 [77.5 kB]

Get:35 http://us.archive.ubuntu.com/ubuntu/ trusty/main ipxe-qemu all 1.0.0+git-20131111.c3d1e78-2ubuntu1 [506 kB]

Get:36 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libaugeas0 amd64 1.2.0-0ubuntu1.1 [135 kB]

Get:37 http://us.archive.ubuntu.com/ubuntu/ trusty/main libgvnc-1.0-0 amd64 0.5.3-0ubuntu2 [53.2 kB]

Get:38 http://us.archive.ubuntu.com/ubuntu/ trusty/main libgtk-vnc-1.0-0 amd64 0.5.3-0ubuntu2 [22.8 kB]

Get:39 http://us.archive.ubuntu.com/ubuntu/ trusty/main libnetcf1 amd64 1:0.2.3-4ubuntu1 [44.4 kB]

Get:40 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libvirt0 amd64 1.2.2-0ubuntu13.1.2 [830 kB]

Get:41 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libxenstore3.0 amd64 4.4.0-0ubuntu5.1 [18.5 kB]

Get:42 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libxen-4.4 amd64 4.4.0-0ubuntu5.1 [272 kB]

Get:43 http://us.archive.ubuntu.com/ubuntu/ trusty/main cgroup-lite all 1.9 [3,918 B]

Get:44 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libvirt-bin amd64 1.2.2-0ubuntu13.1.2 [2,064 kB]

Get:45 http://us.archive.ubuntu.com/ubuntu/ trusty/main libvte-common all 1:0.28.2-5ubuntu1 [22.8 kB]

Get:46 http://us.archive.ubuntu.com/ubuntu/ trusty/main libvte9 amd64 1:0.28.2-5ubuntu1 [374 kB]

Get:47 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libxml2-utils amd64 2.9.1+dfsg1-3ubuntu4.3 [34.7 kB]

Get:48 http://us.archive.ubuntu.com/ubuntu/ trusty/main python-appindicator amd64 12.10.1+13.10.20130920-0ubuntu4 [7,706 B]

Get:49 http://us.archive.ubuntu.com/ubuntu/ trusty/main python-glade2 amd64 2.24.0-3ubuntu3 [8,744 B]

Get:50 http://us.archive.ubuntu.com/ubuntu/ trusty/main python-pyorbit amd64 2.24.0-6ubuntu4 [57.2 kB]

Get:51 http://us.archive.ubuntu.com/ubuntu/ trusty/main python-gnome2 amd64 2.28.1+dfsg-1ubuntu2 [136 kB]

Get:52 http://us.archive.ubuntu.com/ubuntu/ trusty/main python-gtk-vnc amd64 0.5.3-0ubuntu2 [8,686 B]

Get:53 http://us.archive.ubuntu.com/ubuntu/ trusty/main python-libvirt amd64 1.2.2-0ubuntu1 [97.6 kB]

Get:54 http://us.archive.ubuntu.com/ubuntu/ trusty/main python-urlgrabber all 3.9.1-4ubuntu3 [42.3 kB]

Get:55 http://us.archive.ubuntu.com/ubuntu/ trusty/main python-vte amd64 1:0.28.2-5ubuntu1 [21.7 kB]

Get:56 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main qemu-keymaps all 2.0.0+dfsg-2ubuntu1.3 [20.9 kB]

Get:57 http://us.archive.ubuntu.com/ubuntu/ trusty/main seabios all 1.7.4-4 [108 kB]

Get:58 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main qemu-system-x86 amd64 2.0.0+dfsg-2ubuntu1.3 [1,940 kB]

Get:59 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main qemu-kvm amd64 2.0.0+dfsg-2ubuntu1.3 [7,120 B]

Get:60 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main qemu-utils amd64 2.0.0+dfsg-2ubuntu1.3 [414 kB]

Get:61 http://us.archive.ubuntu.com/ubuntu/ trusty/main sharutils amd64 1:4.14-1ubuntu1 [145 kB]

Get:62 http://us.archive.ubuntu.com/ubuntu/ trusty/main virtinst all 0.600.4-3ubuntu2 [179 kB]

Get:63 http://us.archive.ubuntu.com/ubuntu/ trusty/main virt-manager all 0.9.5-1ubuntu3 [280 kB]

Get:64 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main openvswitch-common amd64 2.0.2-0ubuntu0.14.04.1 [444 kB]

Get:65 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main openvswitch-switch amd64 2.0.2-0ubuntu0.14.04.1 [863 kB]

Fetched 13.8 MB in 11s (1,206 kB/s)

Extracting templates from packages: 100%

Selecting previously unselected package libsigsegv2:amd64.

(Reading database ... 194800 files and directories currently installed.)

Preparing to unpack .../libsigsegv2_2.10-2_amd64.deb ...

Unpacking libsigsegv2:amd64 (2.10-2) ...

Setting up libsigsegv2:amd64 (2.10-2) ...

Processing triggers for libc-bin (2.19-0ubuntu6) ...

Selecting previously unselected package gawk.

(Reading database ... 194808 files and directories currently installed.)

Preparing to unpack .../gawk_1%3a4.0.1+dfsg-2.1ubuntu2_amd64.deb ...

Unpacking gawk (1:4.0.1+dfsg-2.1ubuntu2) ...

Selecting previously unselected package libaio1:amd64.

Preparing to unpack .../libaio1_0.3.109-4_amd64.deb ...

Unpacking libaio1:amd64 (0.3.109-4) ...

Selecting previously unselected package libindicator7.

Preparing to unpack .../libindicator7_12.10.2+14.04.20140402-0ubuntu1_amd64.deb ...

Unpacking libindicator7 (12.10.2+14.04.20140402-0ubuntu1) ...

Selecting previously unselected package libappindicator1.

Preparing to unpack .../libappindicator1_12.10.1+13.10.20130920-0ubuntu4_amd64.deb ...

Unpacking libappindicator1 (12.10.1+13.10.20130920-0ubuntu4) ...

Selecting previously unselected package libbonobo2-common.

Preparing to unpack .../libbonobo2-common_2.32.1-0ubuntu5_all.deb ...

Unpacking libbonobo2-common (2.32.1-0ubuntu5) ...

Selecting previously unselected package libidl-common.

Preparing to unpack .../libidl-common_0.8.14-0.2ubuntu4_all.deb ...

Unpacking libidl-common (0.8.14-0.2ubuntu4) ...

Selecting previously unselected package libidl0:amd64.

Preparing to unpack .../libidl0_0.8.14-0.2ubuntu4_amd64.deb ...

Unpacking libidl0:amd64 (0.8.14-0.2ubuntu4) ...

Selecting previously unselected package liborbit-2-0:amd64.

Preparing to unpack .../liborbit-2-0_1%3a2.14.19-0.3_amd64.deb ...

Unpacking liborbit-2-0:amd64 (1:2.14.19-0.3) ...

Selecting previously unselected package liborbit2:amd64.

Preparing to unpack .../liborbit2_1%3a2.14.19-0.3_amd64.deb ...

Unpacking liborbit2:amd64 (1:2.14.19-0.3) ...

Selecting previously unselected package libbonobo2-0:amd64.

Preparing to unpack .../libbonobo2-0_2.32.1-0ubuntu5_amd64.deb ...

Unpacking libbonobo2-0:amd64 (2.32.1-0ubuntu5) ...

Selecting previously unselected package libglade2-0:amd64.

Preparing to unpack .../libglade2-0_1%3a2.6.4-2_amd64.deb ...

Unpacking libglade2-0:amd64 (1:2.6.4-2) ...

Selecting previously unselected package libgnomevfs2-common.

Preparing to unpack .../libgnomevfs2-common_1%3a2.24.4-1ubuntu6_amd64.deb ...

Unpacking libgnomevfs2-common (1:2.24.4-1ubuntu6) ...

Selecting previously unselected package libgnomevfs2-0:amd64.

Preparing to unpack .../libgnomevfs2-0_1%3a2.24.4-1ubuntu6_amd64.deb ...

Unpacking libgnomevfs2-0:amd64 (1:2.24.4-1ubuntu6) ...

Selecting previously unselected package libgnome2-common.

Preparing to unpack .../libgnome2-common_2.32.1-4ubuntu1_all.deb ...

Unpacking libgnome2-common (2.32.1-4ubuntu1) ...

Selecting previously unselected package libgnome2-bin.

Preparing to unpack .../libgnome2-bin_2.32.1-4ubuntu1_amd64.deb ...

Unpacking libgnome2-bin (2.32.1-4ubuntu1) ...

Selecting previously unselected package libgnome2-0:amd64.

Preparing to unpack .../libgnome2-0_2.32.1-4ubuntu1_amd64.deb ...

Unpacking libgnome2-0:amd64 (2.32.1-4ubuntu1) ...

Selecting previously unselected package libgnomecanvas2-common.

Preparing to unpack .../libgnomecanvas2-common_2.30.3-2_all.deb ...

Unpacking libgnomecanvas2-common (2.30.3-2) ...

Selecting previously unselected package libgnomecanvas2-0:amd64.

Preparing to unpack .../libgnomecanvas2-0_2.30.3-2_amd64.deb ...

Unpacking libgnomecanvas2-0:amd64 (2.30.3-2) ...

Selecting previously unselected package libbonoboui2-common.

Preparing to unpack .../libbonoboui2-common_2.24.5-0ubuntu3_all.deb ...

Unpacking libbonoboui2-common (2.24.5-0ubuntu3) ...

Selecting previously unselected package libbonoboui2-0:amd64.

Preparing to unpack .../libbonoboui2-0_2.24.5-0ubuntu3_amd64.deb ...

Unpacking libbonoboui2-0:amd64 (2.24.5-0ubuntu3) ...

Selecting previously unselected package libboost-thread1.54.0:amd64.

Preparing to unpack .../libboost-thread1.54.0_1.54.0-4ubuntu3.1_amd64.deb ...

Unpacking libboost-thread1.54.0:amd64 (1.54.0-4ubuntu3.1) ...

Selecting previously unselected package libgnomeui-common.

Preparing to unpack .../libgnomeui-common_2.24.5-3_all.deb ...

Unpacking libgnomeui-common (2.24.5-3) ...

Selecting previously unselected package libgnomeui-0:amd64.

Preparing to unpack .../libgnomeui-0_2.24.5-3_amd64.deb ...

Unpacking libgnomeui-0:amd64 (2.24.5-3) ...

Selecting previously unselected package librados2.

Preparing to unpack .../librados2_0.80.5-0ubuntu0.14.04.1_amd64.deb ...

Unpacking librados2 (0.80.5-0ubuntu0.14.04.1) ...

Selecting previously unselected package librbd1.

Preparing to unpack .../librbd1_0.80.5-0ubuntu0.14.04.1_amd64.deb ...

Unpacking librbd1 (0.80.5-0ubuntu0.14.04.1) ...

Selecting previously unselected package libsdl1.2debian:amd64.

Preparing to unpack .../libsdl1.2debian_1.2.15-8ubuntu1.1_amd64.deb ...

Unpacking libsdl1.2debian:amd64 (1.2.15-8ubuntu1.1) ...

Selecting previously unselected package libseccomp2:amd64.

Preparing to unpack .../libseccomp2_2.1.0+dfsg-1_amd64.deb ...

Unpacking libseccomp2:amd64 (2.1.0+dfsg-1) ...

Selecting previously unselected package libusbredirparser1:amd64.

Preparing to unpack .../libusbredirparser1_0.6-2ubuntu1_amd64.deb ...

Unpacking libusbredirparser1:amd64 (0.6-2ubuntu1) ...

Selecting previously unselected package qemu-system-common.

Preparing to unpack .../qemu-system-common_2.0.0+dfsg-2ubuntu1.3_amd64.deb ...

Unpacking qemu-system-common (2.0.0+dfsg-2ubuntu1.3) ...

Selecting previously unselected package libfdt1:amd64.

Preparing to unpack .../libfdt1_1.4.0+dfsg-1_amd64.deb ...

Unpacking libfdt1:amd64 (1.4.0+dfsg-1) ...

Selecting previously unselected package augeas-lenses.

Preparing to unpack .../augeas-lenses_1.2.0-0ubuntu1.1_all.deb ...

Unpacking augeas-lenses (1.2.0-0ubuntu1.1) ...

Selecting previously unselected package bridge-utils.

Preparing to unpack .../bridge-utils_1.5-6ubuntu2_amd64.deb ...

Unpacking bridge-utils (1.5-6ubuntu2) ...

Selecting previously unselected package ebtables.

Preparing to unpack .../ebtables_2.0.10.4-3ubuntu1_amd64.deb ...

Unpacking ebtables (2.0.10.4-3ubuntu1) ...

Selecting previously unselected package ipxe-qemu.

Preparing to unpack .../ipxe-qemu_1.0.0+git-20131111.c3d1e78-2ubuntu1_all.deb ...

Unpacking ipxe-qemu (1.0.0+git-20131111.c3d1e78-2ubuntu1) ...

Selecting previously unselected package libaugeas0.

Preparing to unpack .../libaugeas0_1.2.0-0ubuntu1.1_amd64.deb ...

Unpacking libaugeas0 (1.2.0-0ubuntu1.1) ...

Selecting previously unselected package libgvnc-1.0-0.

Preparing to unpack .../libgvnc-1.0-0_0.5.3-0ubuntu2_amd64.deb ...

Unpacking libgvnc-1.0-0 (0.5.3-0ubuntu2) ...

Selecting previously unselected package libgtk-vnc-1.0-0.

Preparing to unpack .../libgtk-vnc-1.0-0_0.5.3-0ubuntu2_amd64.deb ...

Unpacking libgtk-vnc-1.0-0 (0.5.3-0ubuntu2) ...

Selecting previously unselected package libnetcf1.

Preparing to unpack .../libnetcf1_1%3a0.2.3-4ubuntu1_amd64.deb ...

Unpacking libnetcf1 (1:0.2.3-4ubuntu1) ...

Selecting previously unselected package libvirt0.

Preparing to unpack .../libvirt0_1.2.2-0ubuntu13.1.2_amd64.deb ...

Unpacking libvirt0 (1.2.2-0ubuntu13.1.2) ...

Selecting previously unselected package libxenstore3.0.

Preparing to unpack .../libxenstore3.0_4.4.0-0ubuntu5.1_amd64.deb ...

Unpacking libxenstore3.0 (4.4.0-0ubuntu5.1) ...

Selecting previously unselected package libxen-4.4.

Preparing to unpack .../libxen-4.4_4.4.0-0ubuntu5.1_amd64.deb ...

Unpacking libxen-4.4 (4.4.0-0ubuntu5.1) ...

Selecting previously unselected package cgroup-lite.

Preparing to unpack .../cgroup-lite_1.9_all.deb ...

Unpacking cgroup-lite (1.9) ...

Selecting previously unselected package libvirt-bin.

Preparing to unpack .../libvirt-bin_1.2.2-0ubuntu13.1.2_amd64.deb ...

Unpacking libvirt-bin (1.2.2-0ubuntu13.1.2) ...

Selecting previously unselected package libvte-common.

Preparing to unpack .../libvte-common_1%3a0.28.2-5ubuntu1_all.deb ...

Unpacking libvte-common (1:0.28.2-5ubuntu1) ...

Selecting previously unselected package libvte9.

Preparing to unpack .../libvte9_1%3a0.28.2-5ubuntu1_amd64.deb ...

Unpacking libvte9 (1:0.28.2-5ubuntu1) ...

Selecting previously unselected package libxml2-utils.

Preparing to unpack .../libxml2-utils_2.9.1+dfsg1-3ubuntu4.3_amd64.deb ...

Unpacking libxml2-utils (2.9.1+dfsg1-3ubuntu4.3) ...

Selecting previously unselected package python-appindicator.

Preparing to unpack .../python-appindicator_12.10.1+13.10.20130920-0ubuntu4_amd64.deb ...

Unpacking python-appindicator (12.10.1+13.10.20130920-0ubuntu4) ...

Selecting previously unselected package python-glade2.

Preparing to unpack .../python-glade2_2.24.0-3ubuntu3_amd64.deb ...

Unpacking python-glade2 (2.24.0-3ubuntu3) ...

Selecting previously unselected package python-pyorbit.

Preparing to unpack .../python-pyorbit_2.24.0-6ubuntu4_amd64.deb ...

Unpacking python-pyorbit (2.24.0-6ubuntu4) ...

Selecting previously unselected package python-gnome2.

Preparing to unpack .../python-gnome2_2.28.1+dfsg-1ubuntu2_amd64.deb ...

Unpacking python-gnome2 (2.28.1+dfsg-1ubuntu2) ...

Selecting previously unselected package python-gtk-vnc.

Preparing to unpack .../python-gtk-vnc_0.5.3-0ubuntu2_amd64.deb ...

Unpacking python-gtk-vnc (0.5.3-0ubuntu2) ...

Selecting previously unselected package python-libvirt.

Preparing to unpack .../python-libvirt_1.2.2-0ubuntu1_amd64.deb ...

Unpacking python-libvirt (1.2.2-0ubuntu1) ...

Selecting previously unselected package python-urlgrabber.

Preparing to unpack .../python-urlgrabber_3.9.1-4ubuntu3_all.deb ...

Unpacking python-urlgrabber (3.9.1-4ubuntu3) ...

Selecting previously unselected package python-vte.

Preparing to unpack .../python-vte_1%3a0.28.2-5ubuntu1_amd64.deb ...

Unpacking python-vte (1:0.28.2-5ubuntu1) ...

Selecting previously unselected package qemu-keymaps.

Preparing to unpack .../qemu-keymaps_2.0.0+dfsg-2ubuntu1.3_all.deb ...

Unpacking qemu-keymaps (2.0.0+dfsg-2ubuntu1.3) ...

Selecting previously unselected package seabios.

Preparing to unpack .../seabios_1.7.4-4_all.deb ...

Unpacking seabios (1.7.4-4) ...

Selecting previously unselected package qemu-system-x86.

Preparing to unpack .../qemu-system-x86_2.0.0+dfsg-2ubuntu1.3_amd64.deb ...

Unpacking qemu-system-x86 (2.0.0+dfsg-2ubuntu1.3) ...

Selecting previously unselected package qemu-kvm.

Preparing to unpack .../qemu-kvm_2.0.0+dfsg-2ubuntu1.3_amd64.deb ...

Unpacking qemu-kvm (2.0.0+dfsg-2ubuntu1.3) ...

Selecting previously unselected package qemu-utils.

Preparing to unpack .../qemu-utils_2.0.0+dfsg-2ubuntu1.3_amd64.deb ...

Unpacking qemu-utils (2.0.0+dfsg-2ubuntu1.3) ...

Selecting previously unselected package sharutils.

Preparing to unpack .../sharutils_1%3a4.14-1ubuntu1_amd64.deb ...

Unpacking sharutils (1:4.14-1ubuntu1) ...

Selecting previously unselected package virtinst.

Preparing to unpack .../virtinst_0.600.4-3ubuntu2_all.deb ...

Unpacking virtinst (0.600.4-3ubuntu2) ...

Selecting previously unselected package virt-manager.

Preparing to unpack .../virt-manager_0.9.5-1ubuntu3_all.deb ...

Unpacking virt-manager (0.9.5-1ubuntu3) ...

Selecting previously unselected package openvswitch-common.

Preparing to unpack .../openvswitch-common_2.0.2-0ubuntu0.14.04.1_amd64.deb ...

Unpacking openvswitch-common (2.0.2-0ubuntu0.14.04.1) ...

Selecting previously unselected package openvswitch-switch.

Preparing to unpack .../openvswitch-switch_2.0.2-0ubuntu0.14.04.1_amd64.deb ...

Unpacking openvswitch-switch (2.0.2-0ubuntu0.14.04.1) ...

Processing triggers for man-db (2.6.7.1-1) ...

Processing triggers for gconf2 (3.2.6-0ubuntu2) ...

Processing triggers for ureadahead (0.100.0-16) ...

ureadahead will be reprofiled on next reboot

Processing triggers for install-info (5.2.0.dfsg.1-2) ...

Processing triggers for hicolor-icon-theme (0.13-1) ...

Processing triggers for gnome-menus (3.10.1-0ubuntu2) ...

Processing triggers for desktop-file-utils (0.22-1ubuntu1) ...

Processing triggers for bamfdaemon (0.5.1+14.04.20140409-0ubuntu1) ...

Rebuilding /usr/share/applications/bamf-2.index...

Processing triggers for mime-support (3.54ubuntu1) ...

Setting up gawk (1:4.0.1+dfsg-2.1ubuntu2) ...

Setting up libaio1:amd64 (0.3.109-4) ...

Setting up libindicator7 (12.10.2+14.04.20140402-0ubuntu1) ...

Setting up libappindicator1 (12.10.1+13.10.20130920-0ubuntu4) ...

Setting up libbonobo2-common (2.32.1-0ubuntu5) ...

Setting up libidl-common (0.8.14-0.2ubuntu4) ...

Setting up libidl0:amd64 (0.8.14-0.2ubuntu4) ...

Setting up liborbit-2-0:amd64 (1:2.14.19-0.3) ...

Setting up liborbit2:amd64 (1:2.14.19-0.3) ...

Setting up libbonobo2-0:amd64 (2.32.1-0ubuntu5) ...

Setting up libglade2-0:amd64 (1:2.6.4-2) ...

Setting up libgnomevfs2-common (1:2.24.4-1ubuntu6) ...

Setting up libgnomevfs2-0:amd64 (1:2.24.4-1ubuntu6) ...

Setting up libgnome2-common (2.32.1-4ubuntu1) ...

Setting up libgnomecanvas2-common (2.30.3-2) ...

Setting up libgnomecanvas2-0:amd64 (2.30.3-2) ...

Setting up libbonoboui2-common (2.24.5-0ubuntu3) ...

Setting up libboost-thread1.54.0:amd64 (1.54.0-4ubuntu3.1) ...

Setting up libgnomeui-common (2.24.5-3) ...

Setting up librados2 (0.80.5-0ubuntu0.14.04.1) ...

Setting up librbd1 (0.80.5-0ubuntu0.14.04.1) ...

Setting up libsdl1.2debian:amd64 (1.2.15-8ubuntu1.1) ...

Setting up libseccomp2:amd64 (2.1.0+dfsg-1) ...

Setting up libusbredirparser1:amd64 (0.6-2ubuntu1) ...

Setting up qemu-system-common (2.0.0+dfsg-2ubuntu1.3) ...

Setting up libfdt1:amd64 (1.4.0+dfsg-1) ...

Setting up augeas-lenses (1.2.0-0ubuntu1.1) ...

Setting up bridge-utils (1.5-6ubuntu2) ...

Setting up ebtables (2.0.10.4-3ubuntu1) ...

Setting up ipxe-qemu (1.0.0+git-20131111.c3d1e78-2ubuntu1) ...

Setting up libaugeas0 (1.2.0-0ubuntu1.1) ...

Setting up libgvnc-1.0-0 (0.5.3-0ubuntu2) ...

Setting up libgtk-vnc-1.0-0 (0.5.3-0ubuntu2) ...

Setting up libnetcf1 (1:0.2.3-4ubuntu1) ...

Setting up libvirt0 (1.2.2-0ubuntu13.1.2) ...

Setting up libxenstore3.0 (4.4.0-0ubuntu5.1) ...

Setting up libxen-4.4 (4.4.0-0ubuntu5.1) ...

Setting up cgroup-lite (1.9) ...

cgroup-lite start/running

Setting up libvte-common (1:0.28.2-5ubuntu1) ...

Setting up libvte9 (1:0.28.2-5ubuntu1) ...

Setting up libxml2-utils (2.9.1+dfsg1-3ubuntu4.3) ...

Setting up python-appindicator (12.10.1+13.10.20130920-0ubuntu4) ...

Setting up python-glade2 (2.24.0-3ubuntu3) ...

Setting up python-pyorbit (2.24.0-6ubuntu4) ...

Setting up python-gtk-vnc (0.5.3-0ubuntu2) ...

Setting up python-libvirt (1.2.2-0ubuntu1) ...

Setting up python-urlgrabber (3.9.1-4ubuntu3) ...

Setting up python-vte (1:0.28.2-5ubuntu1) ...

Setting up qemu-keymaps (2.0.0+dfsg-2ubuntu1.3) ...

Setting up seabios (1.7.4-4) ...

Setting up qemu-system-x86 (2.0.0+dfsg-2ubuntu1.3) ...

qemu-kvm start/running

Setting up qemu-utils (2.0.0+dfsg-2ubuntu1.3) ...

Setting up sharutils (1:4.14-1ubuntu1) ...

Setting up virtinst (0.600.4-3ubuntu2) ...

Setting up openvswitch-common (2.0.2-0ubuntu0.14.04.1) ...

Setting up openvswitch-switch (2.0.2-0ubuntu0.14.04.1) ...

openvswitch-switch start/running

Processing triggers for ureadahead (0.100.0-16) ...

Setting up libvirt-bin (1.2.2-0ubuntu13.1.2) ...

Adding group `libvirtd' (GID 126) ...

Done.

libvirt-bin start/running, process 4716

Setting up libvirt-bin dnsmasq configuration.

Setting up qemu-kvm (2.0.0+dfsg-2ubuntu1.3) ...

Processing triggers for ureadahead (0.100.0-16) ...

Setting up libgnome2-bin (2.32.1-4ubuntu1) ...

Setting up libgnome2-0:amd64 (2.32.1-4ubuntu1) ...

Setting up libbonoboui2-0:amd64 (2.24.5-0ubuntu3) ...

Setting up libgnomeui-0:amd64 (2.24.5-3) ...

Setting up python-gnome2 (2.28.1+dfsg-1ubuntu2) ...

Setting up virt-manager (0.9.5-1ubuntu3) ...

Processing triggers for libc-bin (2.19-0ubuntu6) ...

gstanden@vmem2:~$

gstanden@vmem:~$ sudo apt-get install openvswitch-common openvswitch-controller

gstanden@vmem2:~$ sudo apt-get install openvswitch-common openvswitch-controller | tee log2

Reading package lists...

Building dependency tree...

Reading state information...

openvswitch-common is already the newest version.

openvswitch-common set to manually installed.

The following NEW packages will be installed:

openvswitch-controller openvswitch-pki

0 upgraded, 2 newly installed, 0 to remove and 116 not upgraded.

Need to get 283 kB of archives.

After this operation, 958 kB of additional disk space will be used.

Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main openvswitch-pki all 2.0.2-0ubuntu0.14.04.1 [14.8 kB]

Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main openvswitch-controller amd64 2.0.2-0ubuntu0.14.04.1 [268 kB]

Fetched 283 kB in 0s (341 kB/s)

Selecting previously unselected package openvswitch-pki.

(Reading database ... 196477 files and directories currently installed.)

Preparing to unpack .../openvswitch-pki_2.0.2-0ubuntu0.14.04.1_all.deb ...

Unpacking openvswitch-pki (2.0.2-0ubuntu0.14.04.1) ...

Selecting previously unselected package openvswitch-controller.

Preparing to unpack .../openvswitch-controller_2.0.2-0ubuntu0.14.04.1_amd64.deb ...

Unpacking openvswitch-controller (2.0.2-0ubuntu0.14.04.1) ...

Processing triggers for ureadahead (0.100.0-16) ...

Processing triggers for man-db (2.6.7.1-1) ...

Setting up openvswitch-pki (2.0.2-0ubuntu0.14.04.1) ...

Creating controllerca...

Creating switchca...

Setting up openvswitch-controller (2.0.2-0ubuntu0.14.04.1) ...

* Starting ovs-controller ovs-controller

2014-09-11T01:22:50Z|00001|stream_ssl|INFO|Trusting CA cert from /etc/openvswitch-controller/cacert.pem

(/C=US/ST=CA/O=Open vSwitch/OU=switchca/CN=OVS switchca CA Certificate (2014 Sep 10 20:22:49)) (fingerprint c2:12:1e:ea:b1:9e:d7:79:22:ff:8e:0b:21:98:0d:66:76:b6:11:ac)

...done.

Processing triggers for ureadahead (0.100.0-16) ...

gstanden@vmem2:~$

References: Install a KVM host on Ubuntu 14.04 Trusty Tahr

After OpenvSwitch has been installed verify correct installation and function with following steps as shown below.

gstanden@vmem2:~$ sudo ovs-vsctl show

6c15b7a4-1aac-40fb-b312-563401cd0cc1

ovs_version: "2.0.2"

gstanden@vmem2:~$

After KVM has been installed verify correct installation and function with the following steps as shown below. Be sure to use "sudo".

gstanden@vmem2:~$ sudo virsh -c qemu:///system list

Id Name State

----------------------------------------------------

gstanden@vmem2:~$

Note, If you forgot to use "sudo" in front of the above "virsh" command you will get the following error messages as shown below. Retry the command using "sudo" for correct operation.

gstanden@vmem2:~$ virsh -c qemu:///system list

error: failed to connect to the hypervisor

error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied

gstanden@vmem2:~$

Install OpenSSH Server, DHCP, and UML Utilities

All of these are also installed from the apt-get repositories in this wiki as shown below. These too can probably be installed from source for those who want themost recent version. These repository versions for Ubuntu 14.04.1 have all the features needed.

The uml-utilities package is needed to support the "tunctl" functionality used as part of building the OpenvSwitch.

The openssh-server is needed so that it will be possible to ssh from the KVM guest back to the KVM host. Ubuntu 14.04.1 Desktop version does not come with the openssh-server by default, so it has to be installed.

The uuid package, while not used explicitly in this particular wiki page, is used in other pages on this site related to KVM when creating a new KVM guest from an XML file and a new UUID is needed for the XML guest creation, so it is installed now.

gstanden@vmem2:~$ sudo apt-get install uml-utilities openssh-server isc-dhcp-server uuid | tee log3

Reading package lists...

Building dependency tree...

Reading state information...

The following extra packages will be installed:

libck-connector0 libossp-uuid16 ncurses-term openssh-sftp-server

python-requests python-urllib3 ssh-import-id

Suggested packages:

isc-dhcp-server-ldap rssh molly-guard monkeysphere user-mode-linux

The following NEW packages will be installed:

isc-dhcp-server libck-connector0 libossp-uuid16 ncurses-term openssh-server

openssh-sftp-server python-requests python-urllib3 ssh-import-id

uml-utilities uuid

0 upgraded, 11 newly installed, 0 to remove and 116 not upgraded.

Need to get 1,562 kB of archives.

After this operation, 6,436 kB of additional disk space will be used.

Do you want to continue? [Y/n] Y

Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main libck-connector0 amd64 0.4.5-3.1ubuntu2 [10.5 kB]

Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main isc-dhcp-server amd64 4.2.4-7ubuntu12 [762 kB]

Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty/main libossp-uuid16 amd64 1.6.2-1.3ubuntu1 [29.6 kB]

Get:4 http://us.archive.ubuntu.com/ubuntu/ trusty/main ncurses-term all 5.9+20140118-1ubuntu1 [243 kB]

Get:5 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main openssh-sftp-server amd64 1:6.6p1-2ubuntu2 [34.1 kB]

Get:6 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main openssh-server amd64 1:6.6p1-2ubuntu2 [319 kB]

Get:7 http://us.archive.ubuntu.com/ubuntu/ trusty/main python-urllib3 all 1.7.1-1build1 [38.9 kB]

Get:8 http://us.archive.ubuntu.com/ubuntu/ trusty/main python-requests all 2.2.1-1 [42.5 kB]

Get:9 http://us.archive.ubuntu.com/ubuntu/ trusty/universe uuid amd64 1.6.2-1.3ubuntu1 [10.9 kB]

Get:10 http://us.archive.ubuntu.com/ubuntu/ trusty/main ssh-import-id all 3.21-0ubuntu1 [9,624 B]

Get:11 http://us.archive.ubuntu.com/ubuntu/ trusty/universe uml-utilities amd64 20070815-1.3ubuntu1 [61.9 kB]

Preconfiguring packages ...

Fetched 1,562 kB in 2s (632 kB/s)

Selecting previously unselected package libck-connector0:amd64.

(Reading database ... 196492 files and directories currently installed.)

Preparing to unpack .../libck-connector0_0.4.5-3.1ubuntu2_amd64.deb ...

Unpacking libck-connector0:amd64 (0.4.5-3.1ubuntu2) ...

Selecting previously unselected package isc-dhcp-server.

Preparing to unpack .../isc-dhcp-server_4.2.4-7ubuntu12_amd64.deb ...

Unpacking isc-dhcp-server (4.2.4-7ubuntu12) ...

Selecting previously unselected package libossp-uuid16.

Preparing to unpack .../libossp-uuid16_1.6.2-1.3ubuntu1_amd64.deb ...

Unpacking libossp-uuid16 (1.6.2-1.3ubuntu1) ...

Selecting previously unselected package ncurses-term.

Preparing to unpack .../ncurses-term_5.9+20140118-1ubuntu1_all.deb ...

Unpacking ncurses-term (5.9+20140118-1ubuntu1) ...

Selecting previously unselected package openssh-sftp-server.

Preparing to unpack .../openssh-sftp-server_1%3a6.6p1-2ubuntu2_amd64.deb ...

Unpacking openssh-sftp-server (1:6.6p1-2ubuntu2) ...

Selecting previously unselected package openssh-server.

Preparing to unpack .../openssh-server_1%3a6.6p1-2ubuntu2_amd64.deb ...

Unpacking openssh-server (1:6.6p1-2ubuntu2) ...

Selecting previously unselected package python-urllib3.

Preparing to unpack .../python-urllib3_1.7.1-1build1_all.deb ...

Unpacking python-urllib3 (1.7.1-1build1) ...

Selecting previously unselected package python-requests.

Preparing to unpack .../python-requests_2.2.1-1_all.deb ...

Unpacking python-requests (2.2.1-1) ...

Selecting previously unselected package uuid.

Preparing to unpack .../uuid_1.6.2-1.3ubuntu1_amd64.deb ...

Unpacking uuid (1.6.2-1.3ubuntu1) ...

Selecting previously unselected package ssh-import-id.

Preparing to unpack .../ssh-import-id_3.21-0ubuntu1_all.deb ...

Unpacking ssh-import-id (3.21-0ubuntu1) ...

Selecting previously unselected package uml-utilities.

Preparing to unpack .../uml-utilities_20070815-1.3ubuntu1_amd64.deb ...

Unpacking uml-utilities (20070815-1.3ubuntu1) ...

Processing triggers for man-db (2.6.7.1-1) ...

Processing triggers for ureadahead (0.100.0-16) ...

Processing triggers for ufw (0.34~rc-0ubuntu2) ...

Setting up libck-connector0:amd64 (0.4.5-3.1ubuntu2) ...

Setting up isc-dhcp-server (4.2.4-7ubuntu12) ...

Generating /etc/default/isc-dhcp-server...

isc-dhcp-server start/running, process 6157

isc-dhcp-server6 stop/pre-start, process 6199

Setting up libossp-uuid16 (1.6.2-1.3ubuntu1) ...

Setting up ncurses-term (5.9+20140118-1ubuntu1) ...

Setting up openssh-sftp-server (1:6.6p1-2ubuntu2) ...

Setting up openssh-server (1:6.6p1-2ubuntu2) ...

Creating SSH2 RSA key; this may take some time ...

Creating SSH2 DSA key; this may take some time ...

Creating SSH2 ECDSA key; this may take some time ...

Creating SSH2 ED25519 key; this may take some time ...

ssh start/running, process 6424

Setting up python-urllib3 (1.7.1-1build1) ...

Setting up python-requests (2.2.1-1) ...

Setting up uuid (1.6.2-1.3ubuntu1) ...

Setting up ssh-import-id (3.21-0ubuntu1) ...

Setting up uml-utilities (20070815-1.3ubuntu1) ...

* Starting User-mode networking switch uml_switch

...done.

Processing triggers for libc-bin (2.19-0ubuntu6) ...

Processing triggers for ureadahead (0.100.0-16) ...

Processing triggers for ufw (0.34~rc-0ubuntu2) ...

gstanden@vmem2:~$

Build OpenvSwitch

Create the crt_ovs_sw1.sh Script

Our switch is a modification to some procedures described at the Advanced Networking Page by Jean-Jacques Sarton which I have modified for use with OpenvSwitch. First we can build the OpenvSwitch using the script shown below. You can replace the ip range specified with whatever internal address range you wish to use. Note also that the link to the Jean-Jacques work explains how to create additional ports on the switch when adding additional KVM guests. Note that if you change the address range, you will need to also change the address ranges in the /etc/dhcpd/dhcpd.conf file also shown below.

gstanden@vmem2:~$ chmod +x crt_ovs_sw1.sh

gstanden@vmem2:~$ ls -lrt crt_ovs_sw1.sh

-rwxrwxr-x 1 gstanden gstanden 1834 Sep 10 20:32 crt_ovs_sw1.sh

gstanden@vmem2:~$ cat crt_ovs_sw1.sh

#!/bin/bash

# Requires use of Upstart Script /etc/init/my-network-up.conf to ensure interfaces are up before running.

tunctl -t s1

tunctl -t s2

tunctl -t s3

tunctl -t s4

tunctl -t s5

tunctl -t s6

ip link set s1 up

ip link set s2 up

ip link set s3 up

ip link set s4 up

ip link set s5 up

ip link set s6 up

ovs-vsctl add-br sw1

ovs-vsctl add-port sw1 s1

ovs-vsctl add-port sw1 s2

ovs-vsctl add-port sw1 s3

ovs-vsctl add-port sw1 s4

ovs-vsctl add-port sw1 s5

ovs-vsctl add-port sw1 s6

ip link set up dev sw1

ip addr add 10.207.39.1/24 dev sw1

ip route replace 10.207.39.0/24 dev sw1

# GLS 20140825 Get active external interface dynamically at boot. Tested & works with {wlan0, eth0, bnep0} on NM-manager Ubuntu 14.04.1 Desktop x86_64.

# GLS 20140825 Interface "bnep0" is Blackberry Z30 OS10 Bluetooth Tether.

### BEGIN Get Active EXTIF Dynamcially. ###

function GetInterface

{

ifconfig|egrep -B1 'inet addr'|egrep -A1 'wlan0|eth0|bnep0'|sed '$!N;s/\n/ /' | sed 's/ */ /g' | cut -f1,7 -d' ' | sed 's/ addr//' | head -1 | cut -f1 -d':'

}

function GetIP

{

ifconfig|egrep -B1 'inet addr'|egrep -A1 'wlan0|eth0|bnep0'|sed '$!N;s/\n/ /' | sed 's/ */ /g' | cut -f1,7 -d' ' | sed 's/ addr//' | head -1 | cut -f2 -d':'

}

### END Get Active EXTIF Dynamically. ###

echo ' IP: '$(GetIP)

echo 'Interface: '$(GetInterface)

INTIF="sw1"

EXTIF=$(GetInterface)

# EXTIF="wlan0"

echo 1 > /proc/sys/net/ipv4/ip_forward

# clear existing iptable rules, set a default policy

iptables -P INPUT ACCEPT

iptables -F INPUT

iptables -P OUTPUT ACCEPT

iptables -F OUTPUT

iptables -P FORWARD DROP

iptables -F FORWARD

iptables -t nat -F

# set forwarding and nat rules

iptables -A FORWARD -i $EXTIF -o $INTIF -j ACCEPT

iptables -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT

iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE

service isc-dhcp-server start

gstanden@vmem2:~$

Create the /etc/init/my-network-up.conf Script

Create the /etc/init/my-network-up.conf script as shown below and make sure it is executable.

gstanden@vmem2:~$ sudo vi /etc/init/my-network-up.conf

gstanden@vmem2:~$ sudo chmod +x /etc/init/my-network-up.conf

gstanden@vmem2:~$ ls -l /etc/init/my-network-up.conf

-rwxr-xr-x 1 root root 456 Sep 10 20:40 /etc/init/my-network-up.conf

gstanden@vmem2:~$

gstanden@vmem2:~$ cat /etc/init/my-network-up.conf

# 'my-network-up.conf' - My custom upstart events

#

# These are the scripts that run when a network appears.

description "My custom upstart events"

start on net-device-up # Start a daemon or run a script

stop on net-device-down # (Optional) Stop a daemon, scripts already self-terminate.

script

# You can really put shell script in here, including if/then and tests.

/home/gstanden/crt_ovs_sw1.sh 2>&1 > /home/gstanden/crt_ovs_sw1.log

end script

gstanden@vmem2:~$

If you need to add more ports for additional virtual machines, they can be added using the following commands for example.

gstanden@vmem1:~$ sudo tunctl -t s7

Set 's7' persistent and owned by uid 0

gstanden@vmem1:~$ sudo ip link set s7 up

gstanden@vmem1:~$ sudo ovs-vsctl add-port sw1 s7

Creation of the additional ports can be scripted and methods of doing that are detailed at the reference Advanced Networking Page by Jean-Jacques Sarton

In order to assign ip addresses from DHCP, we need to now configure our DHCP server. Below is an example configuration file with the necessary configuration for assigning DHCP addresses to the KVM guests. Once the configuration file has been edited and saved, it is necessary to restart the DHCP service.

gstanden@vmem2:~$ sudo mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.pkg.install.original

gstanden@vmem2:~$ sudo vi /etc/dhcp/dhcpd.conf

gstanden@vmem2:~$ sudo cat /etc/dhcp/dhcpd.conf

#

# Sample configuration file for ISC dhcpd for Debian

#

# Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as

# configuration file instead of this file.

#

#

# The ddns-updates-style parameter controls whether or not the server will

# attempt to do a DNS update when a lease is confirmed. We default to the

# behavior of the version 2 packages ('none', since DHCP v2 didn't

# have support for DDNS.)

ddns-update-style interim;

ignore client-updates;

# option definitions common to all supported networks...

option domain-name "example.org";

option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 600;

max-lease-time 7200;

# If this DHCP server is the official DHCP server for the local

# network, the authoritative directive should be uncommented.

#authoritative;

# Use this to send dhcp log messages to a different log file (you also

# have to hack syslog.conf to complete the redirection).

log-facility local7;

# No service will be given on this subnet, but declaring it helps the

# DHCP server to understand the network topology.

#subnet 10.152.187.0 netmask 255.255.255.0 {

#}

# This is a very basic subnet declaration.

#subnet 10.254.239.0 netmask 255.255.255.224 {

# range 10.254.239.10 10.254.239.20;

# option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;

#}

# This declaration allows BOOTP clients to get dynamic addresses,

# which we don't really recommend.

#subnet 10.254.239.32 netmask 255.255.255.224 {

# range dynamic-bootp 10.254.239.40 10.254.239.60;

# option broadcast-address 10.254.239.31;

# option routers rtr-239-32-1.example.org;

#}

# A slightly different configuration for an internal subnet.

#subnet 10.5.5.0 netmask 255.255.255.224 {

# range 10.5.5.26 10.5.5.30;

# option domain-name-servers ns1.internal.example.org;

# option domain-name "internal.example.org";

# option routers 10.5.5.1;

# option broadcast-address 10.5.5.31;

# default-lease-time 600;

# max-lease-time 7200;

#}

# Hosts which require special configuration options can be listed in

# host statements. If no address is specified, the address will be

# allocated dynamically (if possible), but the host-specific information

# will still come from the host declaration.

#host passacaglia {

# hardware ethernet 0:0:c0:5d:bd:95;

# filename "vmunix.passacaglia";

# server-name "toccata.fugue.com";

#}

# Fixed IP addresses can also be specified for hosts. These addresses

# should not also be listed as being available for dynamic assignment.

# Hosts for which fixed IP addresses have been specified can boot using

# BOOTP or DHCP. Hosts for which no fixed address is specified can only

# be booted with DHCP, unless there is an address range on the subnet

# to which a BOOTP client is connected which has the dynamic-bootp flag

# set.

#host fantasia {

# hardware ethernet 08:00:07:26:c0:a5;

# fixed-address fantasia.fugue.com;

#}

# You can declare a class of clients and then do address allocation

# based on that. The example below shows a case where all clients

# in a certain class get addresses on the 10.17.224/24 subnet, and all

# other clients get addresses on the 10.0.29/24 subnet.

#class "foo" {

# match if substring (option vendor-class-identifier, 0, 4) = "SUNW";

#}

#shared-network 224-29 {

# subnet 10.17.224.0 netmask 255.255.255.0 {

# option routers rtr-224.example.org;

# }

# subnet 10.0.29.0 netmask 255.255.255.0 {

# option routers rtr-29.example.org;

# }

# pool {

# allow members of "foo";

# range 10.17.224.10 10.17.224.250;

# }

# pool {

# deny members of "foo";

# range 10.0.29.10 10.0.29.230;

# }

#}The uml-utilities package is needed to support the "tunctl" functionality

# used as part of building the OpenvSwitch.

subnet 10.207.39.0 netmask 255.255.255.0 {

# --- default gateway

option routers 10.207.39.1;

option subnet-mask 255.255.255.0;

option domain-name "vmem.org";

option domain-name-servers 10.207.39.1;

# option ntp-servers 10.207.39.1;

range dynamic-bootp 10.207.39.50 10.207.39.254;

default-lease-time 21600;

max-lease-time 43200;

}

gstanden@vmem2:~$ sudo chmod +x /etc/dhcp/dhcpd.conf

gstanden@vmem2:~$ ls -lrt /etc/dhcp/dhcpd.conf

-rwxr-xr-x 1 root root 5145 Sep 10 20:46 /etc/dhcp/dhcpd.conf

gstanden@vmem2:~$

Check status of isc-dhcp-server and restart isc-dhcp-server to effect read of new configuration as shown below.

gstanden@vmem2:~$ sudo service isc-dhcp-server status

isc-dhcp-server stop/waiting

gstanden@vmem2:~$ sudo service isc-dhcp-server restart

stop: Unknown instance:

isc-dhcp-server start/running, process 6887

gstanden@vmem2:~

Reboot the Ubuntu KVM host (in this example a Lenovo W540 Mobile Workstation) to verify that the OpenvSwitch starts and verify start of DHCP server. Expected correct output from the log of the crt_ovs_sw1.sh script, the isc-dhcp-server, and from ovs-vsctl (OpenvSwitch utility) are shown below.

gstanden@vmem2:~$ more crt_ovs_sw1.log

Set 's1' persistent and owned by uid 0

Set 's2' persistent and owned by uid 0

Set 's3' persistent and owned by uid 0

Set 's4' persistent and owned by uid 0

Set 's5' persistent and owned by uid 0

Set 's6' persistent and owned by uid 0

IP: 192.168.1.16

Interface: wlan0isc-dhcp-server start/running, process 2284

gstanden@vmem2:~$ sudo service isc-dhcp-server status

[sudo] password for gstanden:

isc-dhcp-server start/running, process 2284

gstanden@vmem2:~$ sudo ovs-vsctl show

6c15b7a4-1aac-40fb-b312-563401cd0cc1

Bridge "sw1"

Port "s3"

Interface "s3"

Port "s5"

Interface "s5"

Port "s2"

Interface "s2"

Port "sw1"

Interface "sw1"

type: internal

Port "s1"

Interface "s1"

Port "s6"

Interface "s6"

Port "s4"

Interface "s4"

ovs_version: "2.0.2"

gstanden@vmem2:~$

Install Windows 8 KVM Guest

Install bind9 DNS Server

Install bind9 DNS server as shown below.

gstanden@vmem2:~$ sudo apt-get install bind9

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following extra packages will be installed:

bind9utils

Suggested packages:

bind9-doc

The following NEW packages will be installed:

bind9 bind9utils

0 upgraded, 2 newly installed, 0 to remove and 7 not upgraded.

Need to get 432 kB of archives.

After this operation, 1,632 kB of additional disk space will be used.

Do you want to continue? [Y/n] Y

Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main bind9utils amd64 1:9.9.5.dfsg-3 [145 kB]

Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main bind9 amd64 1:9.9.5.dfsg-3 [287 kB]

Fetched 432 kB in 0s (701 kB/s)

Preconfiguring packages ...

Selecting previously unselected package bind9utils.

(Reading database ... 199396 files and directories currently installed.)

Preparing to unpack .../bind9utils_1%3a9.9.5.dfsg-3_amd64.deb ...

Unpacking bind9utils (1:9.9.5.dfsg-3) ...

Selecting previously unselected package bind9.

Preparing to unpack .../bind9_1%3a9.9.5.dfsg-3_amd64.deb ...

Unpacking bind9 (1:9.9.5.dfsg-3) ...

Processing triggers for man-db (2.6.7.1-1) ...

Processing triggers for ureadahead (0.100.0-16) ...

ureadahead will be reprofiled on next reboot

Processing triggers for ufw (0.34~rc-0ubuntu2) ...

Setting up bind9utils (1:9.9.5.dfsg-3) ...

Setting up bind9 (1:9.9.5.dfsg-3) ...

Adding group `bind' (GID 129) ...

Done.

Adding system user `bind' (UID 121) ...

Adding new user `bind' (UID 121) with group `bind' ...

Not creating home directory `/var/cache/bind'.

wrote key file "/etc/bind/rndc.key"

#

* Starting domain name service... bind9 [ OK ]

Processing triggers for ureadahead (0.100.0-16) ...

Processing triggers for ufw (0.34~rc-0ubuntu2) ...

gstanden@vmem2:~$

Configure bind9 DNS Server

Configure Physical Windows8 Paritition as KVM Guest

The instructions and procedure to be used for this are here. A reference here is also used which describes how to import the processor definitions of the KVM host into the KVM guest needed for Windows 8 correct bootup and operation.

Layout of /dev/sda

Check the current partition layout of /dev/sda. With Windows 8 this is UEFI boot system and thus does not use the older partitioning system which limited primary partitions to only 4. This system uses GUID so "gdisk" is used instead of "fdisk" . The program "gdisk" should be present in a default Ubuntu install, but if not, it can be installed using "sudo apt-get install gdisk".

gstanden@vmem2:~$ sudo gdisk -l /dev/sda

[sudo] password for gstanden:

GPT fdisk (gdisk) version 0.8.8

Partition table scan:

MBR: protective

BSD: not present

APM: not present

GPT: present

Found valid GPT with protective MBR; using GPT.

Disk /dev/sda: 2000409264 sectors, 953.9 GiB

Logical sector size: 512 bytes

Disk identifier (GUID): 6C1440F2-7290-484D-86A1-F33DDC9C152E

Partition table holds up to 128 entries

First usable sector is 34, last usable sector is 2000409230

Partitions will be aligned on 2048-sector boundaries

Total free space is 1023638125 sectors (488.1 GiB)

Number Start (sector) End (sector) Size Code Name

1 2048 2050047 1000.0 MiB 2700

2 2050048 2582527 260.0 MiB EF00 EFI system partition

3 2582528 2844671 128.0 MiB 0C01 Microsoft reserved part

4 2844672 413194239 195.7 GiB 0700 Basic data partition

5 948348928 976773119 13.6 GiB 2700

6 413194240 824193023 196.0 GiB 8300

7 824193024 834678783 5.0 GiB 8200

8 834678784 948348927 54.2 GiB 8300

gstanden@vmem2:~$

The partition information can also be viewed using "gparted" partition editor as shown below for additional detail on the nature of each partition as to type, size, and detailed information. As shown below, the first partition is a Lenovo Windows Recovery Partition. The partitions and their natures can be listed as shown below.

Create Master Boot Record File

Create the MBR file as shown below.

gstanden@vmem2:~$ pwd

/home/gstanden

gstanden@vmem2:~$ mkdir kvm

gstanden@vmem2:~$ cd kvm

gstanden@vmem2:~/kvm$ mkdir windows8

gstanden@vmem2:~/kvm$ cd windows8

gstanden@vmem2:~/kvm/windows8$ dd if=/dev/zero of=boot.mbr count=2048

2048+0 records in

2048+0 records out

1048576 bytes (1.0 MB) copied, 0.0113271 s, 92.6 MB/s

gstanden@vmem2:~/kvm/windows8$

Install the package "mdadm" as shown below.

gstanden@vmem2:~/kvm/windows8$ ls -lrt

total 1024

-rw-rw-r-- 1 gstanden gstanden 1048576 Sep 10 22:04 boot.mbr

gstanden@vmem2:~/kvm/windows8$ pwd

/home/gstanden/kvm/windows8

gstanden@vmem2:~/kvm/windows8$ sudo apt-get install mdadm

[sudo] password for gstanden:

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following extra packages will be installed:

postfix

Suggested packages:

procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre sasl2-bin

dovecot-common postfix-cdb postfix-doc

Recommended packages:

default-mta mail-transport-agent

The following NEW packages will be installed:

mdadm postfix

0 upgraded, 2 newly installed, 0 to remove and 116 not upgraded.

Need to get 1,447 kB of archives.

After this operation, 4,799 kB of additional disk space will be used.

Do you want to continue? [Y/n] Y

Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mdadm amd64 3.2.5-5ubuntu4.1 [362 kB]

Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main postfix amd64 2.11.0-1 [1,085 kB]

Fetched 1,447 kB in 1s (1,329 kB/s)

Preconfiguring packages ...

Selecting previously unselected package mdadm.

(Reading database ... 199316 files and directories currently installed.)

Preparing to unpack .../mdadm_3.2.5-5ubuntu4.1_amd64.deb ...

Unpacking mdadm (3.2.5-5ubuntu4.1) ...

Selecting previously unselected package postfix.

Preparing to unpack .../postfix_2.11.0-1_amd64.deb ...

Unpacking postfix (2.11.0-1) ...

Processing triggers for ureadahead (0.100.0-16) ...

ureadahead will be reprofiled on next reboot

Processing triggers for doc-base (0.10.5) ...

Processing 6 added doc-base files...

Processing triggers for man-db (2.6.7.1-1) ...

Processing triggers for ufw (0.34~rc-0ubuntu2) ...

Setting up mdadm (3.2.5-5ubuntu4.1) ...

Generating mdadm.conf... done.

Removing any system startup links for /etc/init.d/mdadm-raid ...

update-initramfs: deferring update (trigger activated)

Generating grub configuration file ...

Found linux image: /boot/vmlinuz-3.13.0-35-generic

Found initrd image: /boot/initrd.img-3.13.0-35-generic

Found linux image: /boot/vmlinuz-3.13.0-32-generic

Found initrd image: /boot/initrd.img-3.13.0-32-generic

Found Windows Boot Manager on /dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi

Adding boot menu entry for EFI firmware configuration

done

* Starting MD monitoring service mdadm --monitor [ OK ]

Setting up postfix (2.11.0-1) ...

Adding group `postfix' (GID 129) ...

Done.

Adding system user `postfix' (UID 121) ...

Adding new user `postfix' (UID 121) with group `postfix' ...

Not creating home directory `/var/spool/postfix'.

Creating /etc/postfix/dynamicmaps.cf

Adding tcp map entry to /etc/postfix/dynamicmaps.cf

Adding sqlite map entry to /etc/postfix/dynamicmaps.cf

Adding group `postdrop' (GID 130) ...

Done.

/etc/aliases does not exist, creating it.

Postfix was not set up. Start with

cp /usr/share/postfix/main.cf.debian /etc/postfix/main.cf

. If you need to make changes, edit

/etc/postfix/main.cf (and others) as needed. To view Postfix configuration

values, see postconf(1).

After modifying main.cf, be sure to run '/etc/init.d/postfix reload'.

Processing triggers for ureadahead (0.100.0-16) ...

Processing triggers for initramfs-tools (0.103ubuntu4.2) ...

update-initramfs: Generating /boot/initrd.img-3.13.0-35-generic

W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.

Processing triggers for ufw (0.34~rc-0ubuntu2) ...

Processing triggers for libc-bin (2.19-0ubuntu6) ...

When the postfix screen appears, select "none" and tab to "Ok" <Enter> to continue as shown below.

Run Modprobe Linear Command

gstanden@vmem2:~/kvm/windows8$ sudo modprobe linear

gstanden@vmem2:~/kvm/windows8

gstanden@vmem2:~/kvm/windows8$ sudo gdisk -l /dev/sda

GPT fdisk (gdisk) version 0.8.8

Partition table scan:

MBR: protective

BSD: not present

APM: not present

GPT: present

Found valid GPT with protective MBR; using GPT.

Disk /dev/sda: 2000409264 sectors, 953.9 GiB

Logical sector size: 512 bytes

Disk identifier (GUID): 6C1440F2-7290-484D-86A1-F33DDC9C152E

Partition table holds up to 128 entries

First usable sector is 34, last usable sector is 2000409230

Partitions will be aligned on 2048-sector boundaries

Total free space is 1023638125 sectors (488.1 GiB)

Number Start (sector) End (sector) Size Code Name

1 2048 2050047 1000.0 MiB 2700

2 2050048 2582527 260.0 MiB EF00 EFI system partition

3 2582528 2844671 128.0 MiB 0C01 Microsoft reserved part

4 2844672 413194239 195.7 GiB 0700 Basic data partition

5 948348928 976773119 13.6 GiB 2700

6 413194240 824193023 196.0 GiB 8300

7 824193024 834678783 5.0 GiB 8200

8 834678784 948348927 54.2 GiB 8300

gstanden@vmem2:~/kvm/windows8$

gstanden@vmem2:~/kvm/windows8$ sudo dd if=/dev/sda2 of=/srv/boot.mbr

532480+0 records in

532480+0 records out

272629760 bytes (273 MB) copied, 0.833061 s, 327 MB/s

gstanden@vmem2:~/kvm/windows8$ ls -lrt /srv/boot.mbr

-rw-r--r-- 1 root root 272629760 Sep 10 22:26 /srv/boot.mbr

gstanden@vmem2:~/kvm/windows8$ sudo losetup /dev/loop0 /srv/boot.mbr

gstanden@vmem2:~/kvm/windows8$

Build KVM Guest Ubuntu Server 14.04.1

For the KVM guest we user Ubuntu Server version. For this it is necessary to download the installation media from Ubuntu website. Once you have downloaded, the iso file can be used for creating the KVM guest as a file. There is no need to burn it to a physical DVD.

Once the software is downloaded, virt-manager is started to do the GUI-based install. Note that KVM also supports command-line non-GUI install. Once the KVM guest has been built, the XML file of the KVM guest will be modified to replace libvirt default networking with OpenvSwitch. Launch virt-manager by going to the ubuntu program launcher and typing the first few letters of the name of the program in the search field, i.e. "virt" and select the "Virtual Machine Manager". Once that is open, click on the icon showing a computer screen with a yellow dot at the upper-right-hand corner to launch the dialog for creating a new KVM guest.

Then create a new virtual machine dialog is displayed next as shown below.

As shown, select a name for your KVM guest machine, for example "kvm1" and also click the radio button for "Local install media (ISO image or CDROM)". Click on next.

Choose the OS type and Version as shown. Then click the "Use ISO image" and click on the "Browse" button which brings up the "Locate ISO media volume" dialog page. Click on the "Browse Local" button.

This brings up the "Locate ISO media" dialog box. Navigate to the location of your downloaded Ubuntu Server 14.04.1 iso file, which in my case is in the /home/gstanden/Downloads folder as shown. Click on "Open". The full path to the ISO is populated. Click on "Forward".

Choosing the ISO file will populate the "New VM - Create a new virtual machine" ISO image field. Click on "Forward".

This brings up the dialog for choosing RAM and number of processors. I normally choose at least "2" for processors so that the installer will opt for the SMP (symmetric multip processor) version of the kernel during install. Click on "Forward".

The summary of the KVM guest to be created is shown. Tick the "Customize configuration before install" box, and also expand the "Advanced Options" so that you can see the additional features. The "Advanced Options" should be set as shown by default. If they are not, set them as shown. Your MAC address will differ from that shown, no need to change it. Click on "Finish".

The KVM guest customizations screen is shown next below.

Click on the option in the left pane "Disk 1" which brings up the customization options for the disk. Set the values as shown in the screenshot below. These values are needed so that the high-performance feature for high KVM guest bandwidth and IOPS called virtio-blk-data-plane can be set for the virtual disk later. The key settings are as follows:

Disk Bus: Virtio

Cache Mode: none

IO mode: native

Verify that the Disk bus, Cache mode, and IO mode are all as indicated above and click on "Apply".

Now click on "Begin Installation" in the upper-left-hand corner on the same dialog box as shown. A smal dialog box will briefly flash showing that the installation is about to begin, and then a new window will open which is the new virtual KVM running the ISO installation file.

Select the language for the new KVM guest as shown. In this case accepted the default of "English". With your cursor inside the KVM window (cursor "captured") simply hit <Enter> to accept "English" as the language.

Note: With KVM, if you need to escape your cursor out of the KVM guest back to the Ubuntu host OS desktop, you can press left <ctrl> + <alt> to escape the cursor from the KVM guest window.

Not all installation dialog screens are shown below as installation of the Ubuntu Server 14.04.1 OS is not the focus of this wiki. However, a few screenshots are included for some screens that are relevant to the topic of this wiki. If you need help installing the Ubuntu Server 14.04.1 OS you can check these references for more information.

[ Add references here ]

The "Install Ubuntu Server" splash screen is shown next. Again, accept defaults as shown, and hit <Enter>.

Several more screens will be presented. Go through the install of the Ubuntu Server 14.04.1 (details are beyond scope of this present wiki). There are many good rereferences on the internet for how to install Ubuntu Server 14.04.1 The installation completes and the KVM guest is rebooted. Login to the screen at the prompt with your username (not root, this is Ubuntu!) and your password.

Modify XML of KVM Guest for OpenvSwitch

The xml of the KVM guest as created uses the default KVM networking. It needs to be changed over to OpenvSwitch. There were some good notes on how to do this here. The section of KVM guest xml that needs to be changed is shown below. The editing of the xml of the KVM guest is done with the command "virsh edit <kvm-guest-name>" as shown below.

gstanden@vmem:~ $ virsh edit kvm1

This command displays the xml in an editor (usually vi by default). The section that needs edit for OpenvSwitch is shown below.

<interface type='network'> <mac address='52:54:00:48:53:03'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface>

It needs to be changed to the following for OpenvSwitch as shown below.

<interface type='bridge'> <mac address='52:54:00:48:53:03'/> <virtualport type='openvswitch'/> <target dev='s1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface>

Save the changes in the usual way. Note that KVM guest xml should not be edited by finding the file on the OS and "vi" it. Normally the edits will not stick when done in that way. Always use "virsh edit <kvm-guest-name>" to edit KVM xml files.

Once you have saved it now use virsh to dump the edited XML so you can see the additional edits that KVM has made automatically as a result of the change to OpenvSwitch as shown below. KVM has added some additional code automatically.

<interface type='bridge'> <mac address='52:54:00:48:53:03'/> <virtualport type='openvswitch'> <parameters interfaceid='4236e500-4303-49de-8bd0-f2517dc5f346'/> </virtualport> <target dev='s1'/> <model type='rtl8139'/> <alias name='net0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface>

As we can see above, the KVM guest has indeed gotten an IP address issued to it on the range we specified for the sw1 switch. Test ssh now to the KVM guest and vice-versa from the KVM host as shown below.

gstanden@vmem1:~$ ssh 10.207.39.51 <-- Now test ssh from the KVM host to the KVM guest. The authenticity of host '10.207.39.51 (10.207.39.51)' can't be established. ECDSA key fingerprint is fb:5b:72:0b:6f:de:cd:a1:13:80:00:41:87:09:e5:48. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.207.39.51' (ECDSA) to the list of known hosts. gstanden@10.207.39.51's password: Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-32-generic x86_64) . .

.

Last login: Fri Aug 8 19:32:23 2014 gstanden@kvm1:~$ ssh 10.207.39.1 <-- Now test ssh in the other direction back to the KVM host. The authenticity of host '10.207.39.1 (10.207.39.1)' can't be established. ECDSA key fingerprint is 44:06:d9:20:e5:d3:cb:dc:c9:76:cc:ea:8b:71:e9:99. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.207.39.1' (ECDSA) to the list of known hosts.

gstanden@10.207.39.1's password:

Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-32-generic x86_64).

. .

.

Last login: Fri Aug 8 10:18:10 2014 from 10.207.39.20

gstanden@vmem1:~$

So now it is no longer necessary to use the virt-manager console to access the KVM guest. We have full ssh access two-way between KVM host and guest. Because the DHCP was built by us for our OpenvSwitch we have full control over the details of our DHCP client as well.

Configure KVM Guest for Console Access

Even though ssh has been established, it would be useful to have console access without having to resort to the GUI virt-manager console which is small and limiting. We can configure console access easily according to the instructions here.

gstanden@kvm1:~$ sudo cp /etc/init/tty1.conf /etc/init/ttyS0.conf [sudo] password for gstanden: gstanden@kvm1:~$ sudo vi /etc/init/ttyS0.conf gstanden@kvm1:~$ cat /etc/init/ttyS0.conf # tty1 - getty # # This service maintains a getty on tty1 from the point the system is # started until it is shut down again. start on stopped rc RUNLEVEL=[2345] and ( not-container or container CONTAINER=lxc or container CONTAINER=lxc-libvirt) stop on runlevel [!2345] respawn exec /sbin/getty -8 115200 ttyS0 xterm gstanden@kvm1:~$

Now edit the following file to tell grub to output all messages to the console as shown below. The line that needs to be edited is "GRUB_CMDLINE_LINUX_DEFAULT" which needs to be set to "console=ttyS0" as shown below (bolded line).

gstanden@kvm1:~$ cat /etc/default/grub # If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. # For full documentation of the options in this file, see: # info -f grub -n 'Simple configuration' GRUB_DEFAULT=0 #GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=2 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0" GRUB_CMDLINE_LINUX="" # Uncomment to enable BadRAM filtering, modify to suit your needs # This works with Linux (no patch required) and with any kernel that obtains # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...) #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef" # Uncomment to disable graphical terminal (grub-pc only) #GRUB_TERMINAL=console # The resolution used on graphical terminal # note that you can use only modes which your graphic card supports via VBE # you can see them in real GRUB with the command `vbeinfo' #GRUB_GFXMODE=640x480 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux #GRUB_DISABLE_LINUX_UUID=true # Uncomment to disable generation of recovery mode menu entries #GRUB_DISABLE_RECOVERY="true" # Uncomment to get a beep at grub start #GRUB_INIT_TUNE="480 440 1" gstanden@kvm1:~$

After making this change, you must update grub as shown below.

gstanden@kvm1:~$ sudo update-grub2 [sudo] password for gstanden: Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.13.0-32-generic Found initrd image: /boot/initrd.img-3.13.0-32-generic Found memtest86+ image: /memtest86+.elf Found memtest86+ image: /memtest86+.bin done gstanden@kvm1:~$

Shutdown the KVM guest after making this change as shown below.

gstanden@kvm1:~$ sudo shutdown -h now [sudo] password for gstanden:

Reboot the KVM guest as shown below and then connect to the console using virsh command. The guest outputs all standard console output now to the terminal session.

gstanden@vmem1:~$ virsh start kvm1 Domain kvm1 started gstanden@vmem1:~$ virsh console kvm1 Connected to domain kvm1 Escape character is ^] ffffff] [ 0.000000] Normal empty [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x00001000-0x0009efff] [ 0.000000] node 0: [mem 0x00100000-0x3fffdfff] [ 0.000000] ACPI: PM-Timer IO Port: 0xb008 . . . * Starting Postfix Mail Transport Agent postfix [ OK ] * Restoring resolver state... [ OK ] * Stopping System V runlevel compatibility [ OK ] Ubuntu 14.04.1 LTS kvm1 ttyS0 kvm1 login: gstanden Password: Last login: Fri Aug 8 21:17:00 CDT 2014 on ttyS0 Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-32-generic x86_64) . . . gstanden@kvm1:~$

Configure DHCP for OpenvSwitch

Some guides available on this topic use the approach of attaching the internet-connected physical interface to the OpenvSwitch to obtain a DHCP address generated by the actual physical network DHCP provider, for example, in a home network, your internet router. The drawback to this is that if the KVM host (my laptop for example) is taken elsewhere (say to Starbucks, a customer site, or an airport) the network providing internet service, and hence the DHCP address assigned to the KVM guest, will change to match the network being used (e.g. Starbucks network). In general, we typically want enterprise KVM guests to have a static IP, or at very least always obtain an IP on the same IP network address range (e.g. 10.207.39.x) so we'd rather that the KVM guest get it's IP from a DHCP source that does not change no matter what network the KVM host is on for it's extenal internet. So that is the primary driver for not deriving IP addresses for the KVM guest when the KVM host is a laptop (in my case a Lenovo W520 Mobile Workstation with 32 Gb of RAM).

The OpenvSwitch "sw1" needs to be able to provide DHCP addresses to the KVM guests. That was why during the packages install isc-dhcp-server package was installed. Now we will configue that dhcp service to deliver IP addresses to KVM guests which are attached to that OpenvSwitch (in this case the switch is called "sw1"). Edit the configuration file as shown below. Once the file has been edited to provide DHCP IP addresses to KVM guests attached to sw1 network, restart the isc-dhcp-server service for the configuration changes to take effect. Note that this part of the configuration is again from the reference at Advanced Networking Page by Jean-Jacques Sarton. I have shown below the entire file, as modified which actually exists on my test system.

gstanden@vmem1:~$ sudo cat /etc/dhcp/dhcpd.conf [sudo] password for gstanden: # # Sample configuration file for ISC dhcpd for Debian # # Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as # configuration file instead of this file. # # # The ddns-updates-style parameter controls whether or not the server will # attempt to do a DNS update when a lease is confirmed. We default to the # behavior of the version 2 packages ('none', since DHCP v2 didn't # have support for DDNS.) ddns-update-style interim; ignore client-updates; # option definitions common to all supported networks... option domain-name "example.org"; option domain-name-servers ns1.example.org, ns2.example.org; default-lease-time 600; max-lease-time 7200; # If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. #authoritative; # Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7; # No service will be given on this subnet, but declaring it helps the # DHCP server to understand the network topology. #subnet 10.152.187.0 netmask 255.255.255.0 { #} # This is a very basic subnet declaration. #subnet 10.254.239.0 netmask 255.255.255.224 { # range 10.254.239.10 10.254.239.20; # option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org; #} # This declaration allows BOOTP clients to get dynamic addresses, # which we don't really recommend. #subnet 10.254.239.32 netmask 255.255.255.224 { # range dynamic-bootp 10.254.239.40 10.254.239.60; # option broadcast-address 10.254.239.31; # option routers rtr-239-32-1.example.org; #} # A slightly different configuration for an internal subnet. #subnet 10.5.5.0 netmask 255.255.255.224 { # range 10.5.5.26 10.5.5.30; # option domain-name-servers ns1.internal.example.org; # option domain-name "internal.example.org"; # option routers 10.5.5.1; # option broadcast-address 10.5.5.31; # default-lease-time 600; # max-lease-time 7200; #} # Hosts which require special configuration options can be listed in # host statements. If no address is specified, the address will be # allocated dynamically (if possible), but the host-specific information # will still come from the host declaration. #host passacaglia { # hardware ethernet 0:0:c0:5d:bd:95; # filename "vmunix.passacaglia"; # server-name "toccata.fugue.com"; #} # Fixed IP addresses can also be specified for hosts. These addresses # should not also be listed as being available for dynamic assignment. # Hosts for which fixed IP addresses have been specified can boot using # BOOTP or DHCP. Hosts for which no fixed address is specified can only # be booted with DHCP, unless there is an address range on the subnet # to which a BOOTP client is connected which has the dynamic-bootp flag # set. #host fantasia { # hardware ethernet 08:00:07:26:c0:a5; # fixed-address fantasia.fugue.com; #} # You can declare a class of clients and then do address allocation # based on that. The example below shows a case where all clients # in a certain class get addresses on the 10.17.224/24 subnet, and all # other clients get addresses on the 10.0.29/24 subnet. #class "foo" { # match if substring (option vendor-class-identifier, 0, 4) = "SUNW"; #} #shared-network 224-29 { # subnet 10.17.224.0 netmask 255.255.255.0 { # option routers rtr-224.example.org; # } # subnet 10.0.29.0 netmask 255.255.255.0 { # option routers rtr-29.example.org; # } # pool { # allow members of "foo"; # range 10.17.224.10 10.17.224.250; # } # pool { # deny members of "foo"; # range 10.0.29.10 10.0.29.230; # } #} subnet 10.207.39.0 netmask 255.255.255.0 { # --- default gateway option routers 10.207.39.1; option subnet-mask 255.255.255.0; option domain-name "vmem.org"; option domain-name-servers 10.207.39.1; # option ntp-servers 10.207.39.1; range dynamic-bootp 10.207.39.50 10.207.39.254; default-lease-time 21600; max-lease-time 43200; } gstanden@vmem1:~$

Note that if you go to the reference quoted above, it shows that the relevant parts of the configuration file that need to be included are those shown below (which are also in my file shown above). Note that as shown below, the "range dynamic-bootp" can be changed to set whatever IP range you want to reserve for DHCP (for example if you wanted to reserve some IP addresses on your network for static assignment). In my case, I have reserved addresses 2-49 for static IP assignments, and addresses 50-254 for DHCP.

ddns-update-style interim; ignore client-updates; subnet 10.207.39.0 netmask 255.255.255.0 { # --- default gateway option routers 10.207.39.1; option subnet-mask 255.255.255.0; option domain-name "vmem.org"; option domain-name-servers 10.207.39.1; # option ntp-servers 10.207.39.1; range dynamic-bootp 10.207.39.50 10.207.39.254; default-lease-time 21600; max-lease-time 43200; }

Now restart the isc-dhcp-server so that it reads the configuration changes and applies them as shown below.

gstanden@vmem1:~$ sudo service isc-dhcp-server restart [sudo] password for gstanden: isc-dhcp-server stop/waiting isc-dhcp-server start/running, process 7697

Verify KVM Guest Obtains IP Address from DHCP on OpenvSwitch

Now reboot the VM and test if the DHCP provides an IP address to the KVM guest as shown below. Note the IP address in bold in bold which was provided by DHCP to the OpenvSwitch on switch sw1.

gstanden@vmem1:~$ virsh start kvm1 Domain kvm1 started gstanden@vmem1:~$ virsh console kvm1 Connected to domain kvm1 Escape character is ^] -root ro console=ttyS0 [ 0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes) [ 0.000000] Checking aperture... [ 0.000000] No AGP bridge found . . . * Starting Postfix Mail Transport Agent postfix [ OK ] * Restoring resolver state... [ OK ] * Stopping System V runlevel compatibility [ OK ] Ubuntu 14.04.1 LTS kvm1 ttyS0 kvm1 login: gstanden Password: Last login: Fri Aug 8 21:20:21 CDT 2014 on ttyS0 Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-32-generic x86_64) . . . gstanden@kvm1:~$ ifconfig eth0 Link encap:Ethernet HWaddr 52:54:00:48:53:03 inet addr:10.207.39.51 Bcast:10.207.39.255 Mask:255.255.255.0 inet6 addr: fe80::5054:ff:fe48:5303/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:13 errors:0 dropped:0 overruns:0 frame:0 TX packets:21 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1434 (1.4 KB) TX bytes:2106 (2.1 KB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:24 errors:0 dropped:0 overruns:0 frame:0 TX packets:24 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1584 (1.5 KB) TX bytes:1584 (1.5 KB) gstanden@kvm1:~$

Optionally Configuring Static IP Address for KVM Guest

Once DHCP has been verified and is working with the new KVM guest, optionally the KVM guest can easily be set to use static IP addressing (on the same IP range as the DHCP server is providing in this example). To switch your KVM guest to use a static IP on the internet-connected IP range it is necessary to edit the /etc/network/interfaces file inside the KVM guest as shown below.

gstanden@san1:~$ cat /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 10.207.39.51 netmask 255.255.255.0 network 10.207.39.1 broadcast 10.207.39.255 gateway 10.207.39.1 # auto eth0 # iface eth0 inet dhcp gstanden@san1:~$

The file as shown has configured the KVM guest for a static IP. If it was desired to re-configure the KVM guest to obtain an IP address from DHCP, then the file would be changed as shown below.

gstanden@san1:~$ cat /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 # iface eth0 inet static # address 10.207.39.20 # netmask 255.255.255.0 # network 10.207.39.1 # broadcast 10.207.39.255 # gateway 10.207.39.1 auto eth0 iface eth0 inet dhcp gstanden@san1:~$

So as you can see, switching between static and dhcp addressing is quite simple, but is provided for completeness so that it is clear even for those unfamiliar with Ubuntu Server networking files.

Configure DNS for KVM Guest and Host Environments

This is described hereand here at other pages on this blog.

Configure Internet Access for KVM Guest

The KVM guest now has ssh host-guest support, and also has console. What it does not yet have is access to the internet for downloading packages etc. A common way to address this is to attach eth0 (i.e. the public ethernet interface) to the switch. However, there are some issues with this is a desktop environment where Ubuntu network-manager is being used, so a different method is employed simply using iptables rules to provide access to the internet. The reference for this is again from the reference Advanced Networking Page by Jean-Jacques Sarton . The rules used to establish this networking are described in this section as shown below.

gstanden@vmem1:~$ cat crt_nat.sh INTIF="sw1" EXTIF="eth0" echo 1 > /proc/sys/net/ipv4/ip_forward # clear existing iptable rules, set a default policy iptables -P INPUT ACCEPT iptables -F INPUT iptables -P OUTPUT ACCEPT iptables -F OUTPUT iptables -P FORWARD DROP iptables -F FORWARD iptables -t nat -F # set forwarding and nat rules iptables -A FORWARD -i $EXTIF -o $INTIF -j ACCEPT iptables -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE gstanden@vmem1:~$

As stated at the reference Advanced Networking Page by Jean-Jacques Sarton for this method to work, INTIF is set to the name of the OpenvSwitch, and EXTIF is set to the physical interface which is connected to the internet, and then the script is run using sudo as shown below.

gstanden@vmem1:~$ sudo ./crt_nat.sh

First, the /etc/resolv.conf in the guest will have a couple of properties that need to be addressed. As stated at the reference Advanced Networking Page by Jean-Jacques Sarton the /etc/resolv.conf needs to match the same /etc/resolv.conf used by the host. The /etc/resolv.conf used by the host is shown below.

gstanden@vmem1:~$ sudo cat /etc/resolv.conf [sudo] password for gstanden: # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 127.0.1.1 gstanden@vmem1:~$

For the method to be used here to obtain internet for the KVM guest we do not want the host-guest network (i.e. the 10.207.39.1 network) as the nameserver entry in the KVM guest /etc/resolv.conf. However, as the system is currently configured, that network will automatically be assigned and written to the /etc/resolv.conf of the KVM guest. For example, here is how the /etc/resolv.conf looks at this point in the build before the changes we are about to make to change what gets written to the /etc/resolv.conf of the KVM guest on each boot.

gstanden@kvm1:~$ cat /etc/resolv.conf # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 10.207.39.1 search vmem.org gstanden@kvm1:~$

Notice that the /etc/resolv.conf has a commented line that warns that edits by hand to this file will be overwritten. Therefore the file cannot simply be edited by hand. Fortunately, a method for assigning a specific nameserver is described here. At that reference use "Option #3: Configure dhclient.conf". The required change is made on Ubuntu Desktop 14.04.1 on the host machine in the /etc/dhcp/dhclient.conf file. The line that needs to be changed is as follows shown below. Additional information about options for the /etc/dhcp/dhclient.conf is available here.

#prepend domain-name-servers 127.0.0.1;

After the change is made, the file should look like that shown below. Note that it is possible that the prepend line as shown below may get "re-commented out" automatically (this occurred on my system). However, when that happened, there must have been other changes as well because the /etc/resolv.conf from then on simply did not have any nameserver entry at all, which apparently defaults to localhost (127.0.0.1) which has they same effect as setting nameserver to 127.0.0.1 explicity.

gstanden@vmem1:~$ cat /etc/dhcp/dhclient.conf # Configuration file for /sbin/dhclient, which is included in Debian's # dhcp3-client package. # # This is a sample configuration file for dhclient. See dhclient.conf's # man page for more information about the syntax of this file # and a more comprehensive list of the parameters understood by # dhclient. # # Normally, if the DHCP server provides reasonable information and does # not leave anything out (like the domain name, for example), then # few changes must be made to this file, if any. # option rfc3442-classless-static-routes code 121 = array of unsigned integer 8; #send host-name "andare.fugue.com"; send host-name = gethostname(); #send dhcp-client-identifier 1:0:a0:24:ab:fb:9c; #send dhcp-lease-time 3600; #supersede domain-name "fugue.com home.vix.com"; prepend domain-name-servers 127.0.0.1; request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, domain-search, host-name, dhcp6.name-servers, dhcp6.domain-search, netbios-name-servers, netbios-scope, interface-mtu, rfc3442-classless-static-routes, ntp-servers, dhcp6.fqdn, dhcp6.sntp-servers; #require subnet-mask, domain-name-servers; #timeout 60; #retry 60; #reboot 10; #select-timeout 5; #initial-interval 2; #script "/etc/dhcp3/dhclient-script"; #media "-link0 -link1 -link2", "link0 link1"; #reject 192.33.137.209; #alias { # interface "eth0"; # fixed-address 192.5.5.213; # option subnet-mask 255.255.255.255; #} ne #lease { # interface "eth0"; # fixed-address 192.33.137.200; # medium "link0 link1"; # option host-name "andare.swiftmedia.com"; # option subnet-mask 255.255.255.0; # option broadcast-address 192.33.137.255; # option routers 192.33.137.250; # option domain-name-servers 127.0.0.1; # renew 2 2000/1/12 00:00:01; # rebind 2 2000/1/12 00:00:01; # expire 2 2000/1/12 00:00:01; #} gstanden@vmem1:~$

Once all these changes have been made, the /etc/resolv.conf file of the guest will look like either one or the other of the two versions listed below. Make the same change to the /etc/dhcp/dhclient.conf file inside the kvm1 guest as well. After making the changes to these files on both the host and guest, set the files immutable by using "chattr +i /etc/dhcp/dhclient.conf" so that they will not change.

gstanden@san1:~$ cat /etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

Or it might look like this as shown below. However, for the purposes of obtaining internet, either version of the /etc/resolv.conf will work for providing internet service to the KVM guest.

gstanden@san1:~$ cat /etc/resolv.conf # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 127.0.0.1

Enable the As-Built Configuration to Survive Reboots

Summarizing so far we have built a KVM guest, and have set it to use OpenvSwitch "sw1" for networking, and have setup host-guest ssh, internet service for the guest, and console access. Now we would like to add additional LUNs such that those LUNs use and demonstrate two additional features of KVM. Some of the things that have been built are dynamic, in the sense that some of the configurations we have built in the preceding steps won't survive reboot of the KVM host Ubuntu Deskop 14.04.1.

In particular, while to OpenvSwitch "sw1" itself will survive reboots (it's skeletal configuration is stored by OpenvSwitch) other features of the switch "sw1" will not survive reboot without additional steps being implemented. Some of those features that will not survive reboot are the addition of the port "s1" to the switch and the assignment of the ip address 10.209.39.1 to the switch "sw1". Also, the "iptables" rules that were applied will not survive reboot without additonal steps. Finally, the isc-dhcp-server will not start unless the referenced "sw1" and associated port "s1" is ready prior to it starting. So, all of these need to be somehow implemented and started on reboot.

Note that there are many ways that these needed items for reboot could be set to occur at reboot. For example, since this is Ubuntu, the "Upstart" scripting system could be used. It just happens that despite some efforts during my career to get a good handle on "Upstart" script writing, I've never really embraced or understood it very well. I'd like to invite anyone who reads this wiki who has alternative solutions to my solution which are more elegant, more efficient, or even just different for the sake of being different to recommend them in the comments. In my case, I have opted for simply putting a script in the "/etc/rc.local" which takes care of all these things that need to happen on reboot, and it works acceptably for my needs. However, disclaimer, as mentioned, I know that this is probably the least elegant way to do this. Below is my /etc/rc.local and below that is the script that is run from the /etc/rc.local file.

My /etc/rc.local file is shown below. As you can see, in addition to running the necessary script, I also do logging for completeness so that I can see if anything unusual happens during the bootup and run of the crt_ovs.sh script.

gstanden@vmem1:~$ cat /etc/rc.local #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. sudo /home/gstanden/crt_ovs.sh 2>&1 > /home/gstanden/crt_ovs.log sudo chown gstanden:gstanden /home/gstanden/crt_ovs.log exit 0 gstanden@vmem1:~$

Next here is my crt_ovs.sh script as shown below.

gstanden@vmem1:~$ cat crt_ovs.sh # This part sets up the OpenvSwitch tunctl -t s1 ip link set s1 up ovs-vsctl add-br sw1 ovs-vsctl add-port sw1 s1 ip link set up dev sw1 ip addr add 10.207.39.1/24 dev sw1 ip route replace 10.207.39.0/24 dev sw1 # This part sets up internet service for the KVM guest using iptables rules # Change the INTIF and EXTIF to suit your system # INTIF is the name of your OpenvSwitch # EXTIF is the name of your internet-connected interface INTIF="sw1" EXTIF="eth0" echo 1 > /proc/sys/net/ipv4/ip_forward # clear existing iptable rules, set a default policy iptables -P INPUT ACCEPT iptables -F INPUT iptables -P OUTPUT ACCEPT iptables -F OUTPUT iptables -P FORWARD DROP iptables -F FORWARD iptables -t nat -F # set forwarding and nat rules iptables -A FORWARD -i $EXTIF -o $INTIF -j ACCEPT iptables -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE # This part starts the DHCP server for the OpenvSwitch once the switch has been configured above. service isc-dhcp-server start

Configure virtio-blk-data-plane for High IOPS

(1) The virtio-blk-data-plane feature for high bandwidth and IOPs performance in the KVM guest; and

(2) Use of the logical_block_size and physical_block_size parameters to deliver 4K logical/physical sector LUNs to the KVM guest.

To do this we need to add a storage LUN to the KVM guest of type raw *.img. This is because virtio-blk-data-plane has some restrictions as to type of storage LUN that can be used. Currently the restrictions on use of virtio-blk-data-plane are described at the Stefan Hajnoczi blog in the section "When can virtio-blk-data-plane be used". Those restrictions are reproduced here for convenience as shown below.

When can virtio-blk data plane be used? Data plane is suitable for LVM or raw image file configurations where live migration and advanced block features are not needed. This covers many configurations where performance is the top priority. Data plane is still an experimental feature because it only supports a subset of QEMU configurations. The QEMU 1.4 feature has the following limitations: Image formats are not supported (qcow2, qed, etc). Live migration is not supported. QEMU I/O throttling is not supported but cgroups blk-io controller can be used. Only the default "report" I/O error policy is supported (-drive werror=,rerror=). Hot unplug is not supported. Block jobs (block-stream, drive-mirror, block-commit) are not supported.

Please be aware of the above points if considering KVM, especially for any production implementation. The virtio-blk-data-plane technology is powerful for world-record-setting performance, but keep in mind, for example, as shown below, that live migration is not supported when using virtio-blk-data-plane, as well as the other noted points.

So let's add a virtual raw img LUN to the "kvm1" guest and configure it for virtio-blk-data-plane. This wiki shows using the virt-manager GUI to add the virtual storage LUN, but this can also be done with the command line as well.

Open up the virt-manager and open up the kvm1 VM in virt-manager as shown in the screenshot below and highlight the "kvm1" guest and click on the "Open" button in the top left corner area. Be sure to use the button that has "Open" next to it, not the button to the left of it.

Next the "kvm1" guest console opens. We want the GUI information and hardware addition panel, so click the "i" button in the blue circle that is in the upper left corner area of the "kvm1" guest console screen.

Now the "kvm1" guest GUI hardware configuration screen is shown. Click on "Add Hardware" button at lower left of screen.

The "Storage" add hardware dialog is the default dialog for "Add Hardware" so it is displayed. This is the dialog that will be used to create a new virtual LUN for the "kvm1" guest. Be sure to make the selections as shown below (they are non-default settings so they will have to be selected). Set them as follows:

Device type: Virtio disk

Cache mode: none

Storage format: raw

Then click on "Finish".

The "kvm1" hardware overview screen is displayed again. Click on "Virtio Disk 2" to see the properties of the LUN that has just been created.

The properties of the just-created virtual LUN are displayed. As shown, the values should be as follows. It will be necessary to set the IO mode on this screen to "native" as shown below.

Disk bus: Virtio

Storage format: raw

Cache Mode: none

IO mode: native

Note that when changing the IO mode to "native" you will get a dialog box indicating that the change will take effect on the next reboot and the main storage dialog will still say "default". This is normal. The change to native will take effect on the next reboot.

These steps are done. The storage has been added. Now shutdown the "kvm1" guest so that the changes will take affect. Also, be sure to do a "shutdown" and not a "reboot" because we also have to next do a few edits to the "kvm1" guest XML in order to enable virtio-blk-data-plane on the new LUN. The "kvm1" guest can be shutdown from the command line of the "kvm1" guest or it can be done from the virt-manager console by right-click on the virt-manager kvm1 line.

Now the xml is edited according to the instructions provided in the blog from Stefan Hajnoczi at his blog here . However, I provide the actual steps for "kvm1" guest as shown below.

Verify the guest is not running. (Note: it's ok to edit the XML when the guest is running, but I prefer to do it with guest shutdown).

gstanden@vmem1:~$ virsh -c qemu:///system list Id Name State ---------------------------------------------------- gstanden@vmem1:~$

Next edit the xml using the virsh command as shown below. I've also provided a screenshot of how the edited parts should look because this wiki seemed to have some issues with interpreting the XML below as if it was "wiki" XML and not XML from the "kvm1" guest. So here is the screenshot, and after that follows a listing of the XML file for the kvm1 guest.

Note also that KVM virtio disks are numbered starting from "0" (zero). So the second added disk gets the number "1" (one) and so on.

gstanden@vmem1:~$ virsh edit kvm1

The edited xml for the "kvm1" guest when edited successfully will be as shown below. I have bolded the sections that have been changed. NOTE: due to some issues with the way the wikia interprets XML I had to change the lines which is indicated below which starts with "source file" to "5ource file" so that the wikia will not interpret it as wikia XML. Please be sure to use an "s" as shown above in the picture of the edit.

gstanden@vmem1:~$ virsh dumpxml kvm1 <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> <name>kvm1</name> <uuid>db82b8a1-d2ab-0696-28d9-01f88275b880</uuid> <memory unit='KiB'>1048576</memory> <currentMemory unit='KiB'>1048576</currentMemory> <vcpu placement='static'>2</vcpu> <os> <type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/bin/kvm-spice</emulator> <disk type='file' device='disk'> <driver name='qemu' type='raw' cache='none' io='native'/> <source file='/var/lib/libvirt/images/kvm1.img'/> <target dev='vda' bus='virtio'/> <alias name='virtio-disk0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </disk> <disk type='file' device='disk'> <driver name='qemu' type='raw' cache='none' io='native'/> <source file='/var/lib/libvirt/images/kvm1-1.img'/> <target dev='vdb' bus='virtio'/> <alias name='virtio-disk1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </disk> <disk type='block' device='cdrom'> <driver name='qemu' type='raw'/> <target dev='hdc' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk> <controller type='usb' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='pci' index='0' model='pci-root'/> <controller type='ide' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <interface type='bridge'> <mac address='52:54:00:48:53:03'/> <virtualport type='openvswitch'> <parameters interfaceid='4236e500-4303-49de-8bd0-f2517dc5f346'/> </virtualport> <target dev='s1'/> <model type='rtl8139'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> <target port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'/> <sound model='ich6'> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </sound> <video> <model type='cirrus' vram='9216' heads='1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </memballoon> </devices> <qemu:commandline> <qemu:arg value='-set'/> <qemu:arg value='device.virtio-disk0.scsi=off'/> <qemu:arg value='-set'/> <qemu:arg value='device.virtio-disk0.config-wce=off'/> <qemu:arg value='-set'/> <qemu:arg value='device.virtio-disk0.x-data-plane=on'/> <qemu:arg value='-set'/> <qemu:arg value='device.virtio-disk1.scsi=off'/> <qemu:arg value='-set'/> <qemu:arg value='device.virtio-disk1.config-wce=off'/> <qemu:arg value='-set'/> <qemu:arg value='device.virtio-disk1.x-data-plane=on'/> </qemu:commandline> </domain>

Now the "kvm1" guest can be started again using the virsh command as shown below. Once it is up, we can check to make sure that the x-data-plane option (also know as virtio-blk-data-plane) is actually being used and that the XML was configured correctly for virtio-blk-data-plane. If everything has been configured correctly, the x-data-plane values for both virtual disks will be returned as "true". This indicates that the "kvm1" guest is now running with the high bandwidth and high IOPS KVM feature.

gstanden@vmem1:~$ virsh start kvm1 Domain kvm1 started gstanden@vmem1:~$ sudo virsh qemu-monitor-command --hmp kvm1 'info qtree' | grep x-data-plane [sudo] password for gstanden: x-data-plane = true x-data-plane = true gstanden@vmem1:~$

Modify Added LUN to use 4K Logical and 4K Physical Block Size Inside KVM Guest

Examine the added LUN inside the KVM guest to see it's properties. Because I am working on a consumer-grade SSD as my KVM host server storage, the default format of this storage is 512 emulated logical / 4K physical sector size for the physical disk because this is a flash storage device at the KVM host (which are always 4K physical sector size)

Inside the kvm1 guest the format is 512 logical / 512 physical sector sizes. We can see that as shown below.

gstanden@vmem1:~$ sudo fdisk -l /dev/sda6 [sudo] password for gstanden: Disk /dev/sda6: 617.5 GB, 617501163520 bytes 255 heads, 63 sectors/track, 75073 cylinders, total 1206056960 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk identifier: 0x00000000 Disk /dev/sda6 doesn't contain a valid partition table gstanden@vmem1:~$ ssh 10.207.39.51 gstanden@10.207.39.51's password: Last login: Sat Aug 9 12:27:59 2014 from 10.207.39.1 gstanden@kvm1:~$ sudo fdisk -l /dev/vdb [sudo] password for gstanden: Disk /dev/vdb: 8589 MB, 8589934592 bytes 16 heads, 63 sectors/track, 16644 cylinders, total 16777216 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/vdb doesn't contain a valid partition table

However, we would like the /dev/vdb disk inside the "kvm1" guest to be 4K logical/4K physical sector size, so that we the virtual LUN inside the KVM guest will behave logically exactly the same way that a physical 4K logical/4K physical LUN would behave. We can do that by editing the XML of the "kvm1" guest again and making use of some XML settings for this purpose as shown below.

<qemu:commandline> <qemu:arg value='-set'/> <qemu:arg value='device.virtio-disk0.scsi=off'/> <qemu:arg value='-set'/> <qemu:arg value='device.virtio-disk0.config-wce=off'/> <qemu:arg value='-set'/> <qemu:arg value='device.virtio-disk0.x-data-plane=on'/> <qemu:arg value='-set'/> <qemu:arg value='device.virtio-disk1.scsi=off'/> <qemu:arg value='-set'/> <qemu:arg value='device.virtio-disk1.config-wce=off'/> <qemu:arg value='-set'/> <qemu:arg value='device.virtio-disk1.x-data-plane=on'/> <qemu:arg value='-set'/> <qemu:arg value='device.virtio-disk1.logical_block_size=4096'/> <qemu:arg value='-set'/> <qemu:arg value='device.virtio-disk1.physical_block_size=4096'/> </qemu:commandline> </domain>

With the addition of this XML the new LUN will now be presented to the "kvm1" guest as a 4K logical/4K physical LUN. The "kvm1" guest is now shutdown and then restarted (don't use reboot for this) so that we can see the effect of this addition to the XML as shown below.

gstanden@kvm1:~$ sudo fdisk -l /dev/vdb Note: sector size is 4096 (not 512) Disk /dev/vdb: 8589 MB, 8589934592 bytes 16 heads, 56 sectors/track, 2340 cylinders, total 2097152 sectors Units = sectors of 1 * 4096 = 4096 bytes Sector size (logical/physical): 4096 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk identifier: 0x00000000 Disk /dev/vdb doesn't contain a valid partition table gstanden@kvm1:~$

NOTE: A word of caution about switching a LUN to 4K logical / 4K physical sector size. Once the LUN has been used for something, i.e. once data has been written to it, it is NOT feasible to switch it to a different sector sizing because it will cause LOSS of usable data on the LUN. The decision about the sector formatting must be made before the LUN is used for anything.

Similarly, DO NOT convert the LUN on which your KVM guest resides to 4K logical / 4K physical sector size after the machine has been built. That would need to be done at the time of creation of the kvm guest, and it would need to be done only for a kvm guest OS that supports native 4K disk format, and the kvm guest would have to be built with the command line and not the GUI virt-manager because the GUI install method does not have support for the XML parameters mentioned above which set the sector size.

Summary

That's about it. Comments, amplifications, suggestions, are all encouraged from anyone who reads, uses, and has suggestions about this topic. There are many more ways to do some of the things discussed in this wiki, and speaking for myself, I would appreciate if people would share these ideas. The main goal was to show how a fully-functional KVM setup could be built on an Ubuntu Desktop 14.04.1 Laptop environment in such a way that all the excellent enterprise features of KVM, OpenvSwitch, and Advanced Format 4K Flash Storage could be studied in a portable laptop lab environment, complete with a networking setup that provides both DHCP and static addresses, as well as internet access for the KVM guests, all without disrupting the Network-Manager that comes with Ubuntu Desktop 14.04.1. I hope you found it helpful. If you did, please leave a comment. Some of the points to summarize which this wiki was intended to show were the following:

(1) How to build a KVM guest using OpenvSwitch compatible with Network-Manager on a deskop

(2) How to configure DHCP for host-only OpenvSwitch networking and assign DHCP or static addresses to KVM guests

(3) How to establish host-guest two-way ssh over Openvswitch networking

(4) How to establish internet connectivity to the WAN using iptables rules rather than attaching physical interface to OpenvSwitch

(5) How to configure virtio-blk-data-plane for high bandwidth and IOPS inside the KVM guest

(6) How to set the logical sector size and the physical sector size inside the KVM guest.

(7) How to add additional ports to the OpenvSwitch so that additional KVM guests can attach to the OpenvSwitch.

Thank You,

Gilbert Standen

St. Louis, MO

August 2014