KVM Hypervisor on CentOS 6

In this blog we will learn how to set up a KVM hypervisor.

The linux kernel itself is the hypervisor. All we need is to install some user space tools for managing VMs.

# yum install kvm libvirt python-virtinst qemu-kvm bridge-utils

Then we need to start the libvirt daemon

# chkconfig libvirtd on
# /etc/init.d/libvirtd start

and test if it's running. On success it will show an empty list of VMs, on failure it will show an error.

# virsh list

Next thing is to create a bridge and assign the hypervisor's IP to it. Edit /etc/sysconfig/network-scripts/ifcfg-br0

DEVICE="br0"
IPV6INIT="yes"
MTU="1500"
NM_CONTROLLED="yes"
TYPE="Bridge"
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.100
NETMASK=255.255.255.0
GATEWAY=192.168.0.1

Finally we add the hypervisor's eth0 to the bridge. Edit /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE="eth0"
HWADDR="00:19:B9:E2:02:9C"
IPV6INIT="yes"
MTU="1500"
NM_CONTROLLED="yes"
TYPE="Ethernet"
PERSISTENT_DHCLIENT=yes
ONBOOT=yes
BRIDGE=br0

Done. Reboot

social