To install KVM on Centos 6, we first need to install some things.yum groupinstall Virtualization "Virtualization Client" "Virtualization Platform" "Virtualization Tools"
yum -y install bridge-utils avahi ntp ntp-doc ntpdate nano wget
Next, we need to enable the the epel just in case. To do this, we need to download the following rpm's.wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Install and prioritize the repo's. rpm -Uvh epel-release-6*.rpm
Now update everything...yum update
yum upgrade
restart the things and chkconfig the things on.../etc/init.d/messagebus restart
/etc/init.d/avahi-daemon restart
/etc/init.d/libvirtd restart
/sbin/chkconfig messagebus on
/sbin/chkconfig avahi-daemon on
/sbin/chkconfig libvirtd on
Next, set a static ip for your box..nano /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:11:22:33:44:55
ONBOOT=yes
BRIDGE=br0
NM_CONTROLLED=no
/etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
DELAY=0
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.20.254.201
NETMASK=255.255.255.0
GATEWAY=10.20.254.1
NETWORK=10.20.254.0
DNS1=8.8.8.8
DNS2=8.8.4.4
PEERDNS=yes
NM_CONTROLLED=no
Next, let us tell iptables to allow kvm guest to have their networking bridgediptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT
Next, save and restart iptablesservice iptables save
service iptables restart
change your kernel limit...nano /etc/sysctl.conf
# Improve bridge performance
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
apply the changes..sysctl -p
create a group to add kvm libvirt users too..groupadd libvirt
chgrp -R kvm /dev/kvm
usermod -a -G libvirt username
usermod -a -G kvm username
configure selinux to play nice with kvm/etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla
[libvirt Management Access]
# For allowing access to specific user only:
#Identity=unix-user:bozz
# For allowing access to a group (like this guide):
Identity=unix-group:libvirt
Action=org.libvirt.unix.manage
ResultAny=yes
ResultInactive=yes
ResultActive=yes
set the correct permission on the kvm image dir...chown root:libvirt /var/lib/libvirt/images
chmod g+rw /var/lib/libvirt/images
Setup Network Time Protocalchkconfig --levels 235 ntpd on
ntpdate 0.pool.ntp.org
/etc/init.d/ntpd start
Let us get some isos to install vm's from...cd /var/lib/libvirt/images/
wget http://www.gtlib.gatech.edu/pub/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-minimal.iso
wget http://www.gtlib.gatech.edu/pub/ubuntu-releases/12.04.1/ubuntu-12.04.1-server-i386.iso
NOTE: Sometimes you have to delete the default libvirt nat bridge to get bridging to work... brctl delbr virbr0