CentOS / Redhat: Install KVM Virtualization Software

转载 2013年12月03日 09:20:23
VM (Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions Intel VT or AMD-V. How do I install KVM under CentOS or Red Hat Enterprise Linux version 5.5?

The Linux kernel 2.6.20 and above included KVM. RHEL 5.5 (and upcoming RHEL 6) supports KVM out of box and it has also been ported to FreeBSD as a loadable kernel module. However, this tutorial is tested on both CentOS and RHEL 5.5 only running 64 bit Intel Xeon CPU (with Intel VT) and 64 bit kernels with SELinux running in enforcing mode.

Why KVM?

XEN allows several guest operating systems to execute on the same computer hardware and it is also included with RHEL 5.5. But, why use KVM over XEN? KVM is part of the official Linux kernel and fully supported by both Novell and Redhat. Xen boots from GRUB and loads a modified host operating system such as RHEL into the dom0 (host domain). KVM do not have concept of dom0 and domU. It uses /dev/kvm interface to setup the guest operating systems and provides required drivers. See the official wiki for more information.

Required Packages

You must install the following packages:

  1. kmod-kvm : kvm kernel module(s)
  2. kvm : Kernel-based Virtual Machine
  3. kvm-qemu-img : Qemu disk image utility
  4. kvm-tools : KVM debugging and diagnostics tools
  5. python-virtinst : Python modules and utilities for installing virtual machines
  6. virt-manager : Virtual Machine Manager (GUI app, to install and configure VMs)
  7. virt-viewer: Virtual Machine Viewer (another lightweight app to view VM console and/or install VMs)
  8. bridge-utils : Utilities for configuring the Linux Ethernet bridge (this is recommended for KVM networking)

KVM Package Group

RHEL comes with KVM software group which includes full virtualization support with KVM. You can list all packages in the group as follows:
# yum groupinfo KVM
Sample outputs:

Loaded plugins: rhnplugin, security
Setting up Group Process
Group: KVM
 Description: Virtualization Support with KVM
 Mandatory Packages:
 Default Packages:
 Optional Packages:

A Note About libvirt

libvirt is an open source API and management tool for managing platform virtualization. It is used to manage Linux KVM and Xen virtual machines through graphical interfaces such as Virtual Machine Manager and higher level tools such as oVirt. See the official website for more information.

A Note About QEMU

QEMU is a processor emulator that relies on dynamic binary translation to achieve a reasonable speed while being easy to port on new host CPU architectures. When used as a virtualizer, QEMU achieves near native performances by executing the guest code directly on the host CPU. QEMU supports virtualization when executing under the Xen hypervisor or using the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86, server and embedded PowerPC, and S390 guests. See the official website for more information.

A Note About Virtio Drivers

Virtio is paravirtualized drivers for kvm/Linux. With this you can can run multiple virtual machines running unmodified Linux or Windows VMs. Each virtual machine has private virtualized hardware a network card, disk, graphics adapter, etc. According to Redhat:

Para-virtualized drivers enhance the performance of fully virtualized guests. With the para-virtualized drivers guest I/O latency decreases and throughput increases to near bare-metal levels. It is recommended to use the para-virtualized drivers for fully virtualized guests running I/O heavy tasks and applications.

Host Operating System

Your main operating system such as CentOS or RHEL is known as host operating system. KVM is a Linux kernel module that enables a modified QEMU program to use hardware virtualization. You only need to install KVM under host operating systems.

KVM Domains

It is nothing but a guest operating system running under host operating system. Each kvm domain must have a unique name and ID (assigned by system).

Guest Operating Systems

KVM supports various guest operating systems such as

  1. MS-Windows 2008 / 2000 / 2003 Server
  2. MS-Windows 7 / Vista / XP
  3. FreeBSD
  4. OpenBSD
  5. Sun Solaris
  6. Various Linux distributions.
  7. NetBSD
  8. MINIX
  9. QNX
  10. MS DOS
  11. FreeDOS
  12. Haiku
  13. Amiga Research OS

Install KVM

Type the following command to install KVM under RHEL or CentOS:
# yum install kvm virt-viewer virt-manager libvirt libvirt-python python-virtinst
# yum groupinstall KVM

Important Configuration And Log Files (Directories) Location

The following files are required to manage and debug KVM problems:

  1. /etc/libvirt/ - Main configuration directory.
  2. /etc/libvirt/qemu/ - Virtual machine configuration directory. All xml files regarding VMs are stored here. You can edit them manually or via virt-manager.
  3. /etc/libvirt/qemu/networks/ - Networking for your KVM including default NAT. NAT is only recommended for small setup or desktops. I strongly suggest you use bridged based networking for performance.
  4. /etc/libvirt/qemu/networks/default.xml - The default NAT configuration used by NAT device virbr0.
  5. /var/log/libvirt/ - The default log file directory. All VM specific logs files are stored here.
  6. /etc/libvirt/libvirtd.conf - Master libvirtd configuration file.
  7. /etc/libvirt/qemu.conf - Master configuration file for the QEMU driver.


By default libvirt does not opens any TCP or UDP ports. However, you can configure the same by editing the /etc/libvirt/libvirtd.conf file. Also, VNC is configured to listen on by default. To make it listen on all public interfaces, edit /etc/libvirt/qemu.conf file.

Our Sample Setup

                                                                             +-------------> vm#1 ( /, CentOS MySQL Server)
                                                                             +-------------> vm#2 ( /, FreeBSD 7 Web Server)
LAN --> Switch    -->  eth0 --> -+                             |
                                 | ---> br0 -+      +----------------+       +-------------> vm#3 ( /, OpenBSD 4.x Firewall )
                                 |           | ===> |   RHEL Server  |  -----+
                                 |           |      |      KVM       |       +-------------> vm#4 ( /, Solaris 10 Testing Server )
                                 | ---> br1 -+      +----------------+       |
Wan --> ISP Router --> eth1 --> -+                               +-------------> vm#5 ( /, Windows Server Testing Server )
                                                                             +-------------> vm#6 ( /, RHEL Mail Server )

(Fig.01: Our sample server setup - you need to scroll to see complete diagram)


Host Configuration

  • OS - RHEL / CentOS v5.5 is our host operating system.
  • Host has two interface eth0 and eth1
  • LAN - eth0 with private ip
  • Internet - eth1 with public IPv4/IPv6 address.
  • Disk - 73x4 - 15k SAS disk in RAID 10 hardware mode. All VMs are stored on same server (later I will cover SAN/NFS/NAS configuration with live migration).
  • RAM - 16GB ECC
  • CPU - Dual core dual Intel Xeon CPU L5320 @ 1.86GHz with VT enabled in BIOS.

Virtual Machine Configuration

  • Bridged mode networking (eth0 == br0 and eth1 == br1) with full access to both LAN and Internet.
  • Accelerator virtio drivers used for networking (model=virtio)
  • Accelerator virtio drivers for disk (if=virtio) and disk will show up as /dev/vd[a-z][1-9] in VM.
  • Various virtual machines running different guest operating systems as per requirements.



1、centos6的KVM虚拟化安装方法 宿主机的系统安装要求:最小化安装,并使用yum -y update升级至centos6.8。 #安装KVM相关的依赖包和工具包 yum -y g...
  • watermelonbig
  • watermelonbig
  • 2016年11月17日 01:42
  • 1484

CentOS 6.5下安装KVM

  • ztynet
  • ztynet
  • 2017年02月09日 18:54
  • 236

KVM: Fix reboot on Intel hosts补丁分析

kvm模块在初始化的时候,注册了reboot回调:register_reboot_notifier(&kvm_reboot_notifier);在系统reboot的时候,执行如下操作:static i...
  • jemmy858585
  • jemmy858585
  • 2010年10月24日 21:36
  • 782

排除问题提示“Software virtualization is incompatible with long mode on this platform,...”

在我的新笔记本上装好XP虚拟机后,准备开机做进一步的调试。但刚一启动变显示如下一个提示框:     在虚拟机窗框右下角,还有提示:     按照提示...
  • yjzl1911
  • yjzl1911
  • 2014年01月16日 09:24
  • 1607

Software Install for CentOS 7.3

1. NTFS in CentOS7 sudo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.r...
  • ccwwff
  • ccwwff
  • 2017年09月12日 11:53
  • 300

kvm module 初始化

kvm的基本结构分为KVM driver + QEMU,其中KVM是kernel内核的一个模块。主要负责虚拟机的创建,虚拟内存的分配,虚拟cpu寄存器的读写等.QEMU和kvm之前通过IOCTL来通信...
  • tiantao2012
  • tiantao2012
  • 2016年08月05日 15:23
  • 584

VMware9.0安装Ubuntu出现Software virtualization is incompatible 问题的解决

问题描述 刚刚在VMware9.0安装Ubuntu,具体的参考可以见:http://wenku.baidu.com/view/3689981ba2161479171128c5.html 当所有步骤...
  • Grace_0642
  • Grace_0642
  • 2014年01月16日 15:22
  • 2230


  • RHEL_admin
  • RHEL_admin
  • 2015年06月11日 15:45
  • 18215

KVM native 扩展

1.  添加自己的API在目录j2me_cldc/api/src/添加文件test/MyAPI.javapackage test;public class MyAPI{    public nativ...
  • metuu
  • metuu
  • 2011年03月09日 10:07
  • 417


CentOS7使用virt-p2v将RHEL6.7的物理机转化为kvm虚拟机 准备环境: 待转的物理机P:RHEL6.7 安装有virt-v2v工具的conversion server:CentOS7...
  • lbwlh
  • lbwlh
  • 2016年03月29日 11:04
  • 3270
您举报文章:CentOS / Redhat: Install KVM Virtualization Software