Installing kvm on Fedora 20

      No Comments on Installing kvm on Fedora 20

Installing kvm on a recent Fedora OS is quite easy. Fedora already ships all the necessary software packages and kernel modules for running a kernel virtualised machine.

0. Prerequisites

Since late 2005 / early 2006 almost every x86 processor is capable of hardware virtualization. To check if your CPU supports Intel’s VT-d or AMD’s Pacifica, which is a requirement for hardware virtualization with kvm, run:

# egrep '(vmx|svm)' --color=always /proc/cpuinfo

To install the necessary software packages, run:

# yum -y install qemu-kvm libvirt virt-install bridge-utils 

1. Bridge configuration

There are a couple of ways to give your virtual machines access to your network. For a reference, have a look at the Networking page of the kvm documentation. The easiest way is to add the virtual NICs of your virtual machines as well as the physical NIC on your server to a common bridge.

Let’s assume, you have the following ethernet configuration file for your first ethernet device

# Generated by parse-kickstart
UUID=a9e7f9b1-245a-42d6-84b3-865120c16dd6
DNS1=192.168.1.1
BOOTPROTO=none
DEVICE=eth0
ONBOOT=yes
IPV6INIT=yes
HWADDR=00:8C:00:AA:8C:B8
TYPE=Ethernet
IPADDR0=192.168.1.254
PREFIX0=24
GATEWAY0=192.168.1.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME="System eth0"

Let’s create a new bridge device (br0) and add our ethernet device (eth0) to that bridge. First, create a new file called /etc/sysconfig/network-scripts/ifcfg-br0 with the following content:

DNS1=192.168.1.1
BOOTPROTO=none
DEVICE=br0
ONBOOT=yes
IPV6INIT=no
TYPE=Bridge
IPADDR0=192.168.1.254
PREFIX0=24
GATEWAY=192.168.1.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
NM_CONTROLLED=no

Second, we’ll need to alter the configuration file for the ethernet device to add the device to the bridge

DEVICE=eth0
ONBOOT=yes
HWADDR=00:8C:00:AA:8C:B8
BRIDGE=br0
TYPE=Ethernet
NM_CONTROLLED=no

To retrieve the MAC address of your ethernet device (eth0) you can use ip link show:

# ip link show 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT group default qlen 1000
    link/ether 00:8c:00:aa:8c:B8 brd ff:ff:ff:ff:ff:ff

Finally, disable the NetworkManager service, enable the network service and reboot the machine.

# systemctl disable NetworkManager.service
# systemctl enable network.service
# reboot

2. Enable libvirt-daemon

The Fedora packages already have a proper systemd init script, which makes enabling and starting the libvirt-daemon rather easy:

# systemctl enable libvirtd.service 
ln -s '/usr/lib/systemd/system/libvirtd.service' '/etc/systemd/system/multi-user.target.wants/libvirtd.service'
# systemctl start libvirtd.service

You can now go ahead and connect to the libvirt-daemon with a GUI, like virt-manager or install a virtual machine with virt-install.

Leave a Reply

Your email address will not be published.