Terminology I used.
Host - The hypervisor or physical server where all VMs are installed.
VMs (Virtual Machines) - Virtual servers that are installed on top of a physical server
What is Virtualization
Type of Virtualization
Virtualization Advantange
KVM is part of Linux , You may not need to install anything - the 2.6.20 kernel version (and higher) includes KVM kernel modules as part of the mainline kernel.
It support AMD 64 | Intel X86 Hardware
It support Common GUESTs e.g. a. Linux b. BSD c. Windows etc
KVM convert Linux into Type 1 Hypervisor, it used other tools to provide complete set of virtualization. for example if you want to GUI for managing machine then you need to install other packages like virt-manager(Virtual machine manager).
KVM Hypervisor allocate more CPU or memory than the available resources on the system, but it is risky.
KVM Hypervisor uses KSM ( kernel same-page Merging) , it allow GUESTs to share identical memory pages.
KVM Hypervisor support nested virtualization.
Verify CPU Virtualization extension is available
Note :- KVM can also be executed without the CPU extensions, but then, it will run in a pure emulation mode using QEMU, resulting in a significant performance penalty.
Host - The hypervisor or physical server where all VMs are installed.
VMs (Virtual Machines) - Virtual servers that are installed on top of a physical server
What is Virtualization
Type of Virtualization
Virtualization Advantange
What is KVM
KVM stands for Kernel-based Virtual Machine , it is Full Virtualization solution for Linux.KVM is part of Linux , You may not need to install anything - the 2.6.20 kernel version (and higher) includes KVM kernel modules as part of the mainline kernel.
It support AMD 64 | Intel X86 Hardware
It support Common GUESTs e.g. a. Linux b. BSD c. Windows etc
KVM convert Linux into Type 1 Hypervisor, it used other tools to provide complete set of virtualization. for example if you want to GUI for managing machine then you need to install other packages like virt-manager(Virtual machine manager).
Working of kvm.ko (Source Wikipedia) |
KVM Hypervisor uses KSM ( kernel same-page Merging) , it allow GUESTs to share identical memory pages.
KVM Hypervisor support nested virtualization.
Checking KVM Requirement
You can use KVM in pretty much any Linux distro. In general, RedHat flavors favor KVM. RHEL ships with KVM enabled in the operating system, so you can also find it in RedHat-based distros like CentOS Scientific Linux, or Fedora.1. Hardware Support
For full Virtualization KVM hypervisor required processor with virtualization extension. i.e. Intel VT -X(vmx) | AMD-V(SVM)Verify CPU Virtualization extension is available
[root@server ~]# egrep 'svm|vmx' /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts md_clear flush_l1d
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts md_clear flush_l1d
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts md_clear flush_l1d
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts md_clear flush_l1d
[root@server ~]# lscpu | grep Virtualization
Virtualization: VT-x
Virtualization type: full
Note :- It may be necessary to enable hardware virtualization via System BIOS(possibly disable by default)Note :- KVM can also be executed without the CPU extensions, but then, it will run in a pure emulation mode using QEMU, resulting in a significant performance penalty.
2. Kernel Support
KVM require two kernel module to support Full Virtualization- kvm.ko
- kvm_intel.ko(for intel processor) | kvm_amd.ko(for amd processor)
Verify these kernel module available
[root@server ~]# lsmod | grep -i kvm
kvm_intel 245760 0
kvm 745472 1 kvm_intel
irqbypass 16384 1 kvm
Installing KVM
QEMU
KVM uses QEMU for I/O hardware emulation. QEMU is a user-space emulator that can emulate a variety of guest processors on host processors with decent performance. Using the KVM kernel module allows it to approach native speeds. KVM is managed via the libvirt API and tools.Managing KVM Hypervisor
libvirt and libvirt tools
The libvirt package is a hypervisor-independent virtualization API.
It is able to interact with the different Hypervisor.
The libvirt package is available as free software under the GNU Lesser General Public License.
ibvirt supports:
The KVM/QEMU Linux hypervisor
The Xen hypervisor on Linux and Solaris hosts.
The LXC Linux container system
The OpenVZ Linux container system
The User Mode Linux paravirtualized kernel
The VirtualBox hypervisor
The VMware ESX and GSX hypervisors
The VMware Workstation and Player hypervisors
The Microsoft Hyper-V hypervisor
The IBM PowerVM hypervisor
The Virtuozzo hypervisor
The Bhyve hypervisor
Virtual networks using bridging, NAT, VEPA and VN-LINK.
Storage on IDE/SCSI/USB disks, FibreChannel, LVM, iSCSI, NFS and filesystems
libvirt provides:
Remote management using TLS encryption and x509 certificates
Remote management authenticating with Kerberos and SASL
Local access control using PolicyKit
Zero-conf discovery using Avahi multicast-DNS
Management of virtual machines, virtual networks and storage
Portable client API for Linux, Solaris and Windows
virsh
The vi rsh command-line tool is built on the libvirt management API and operates as an alternative to the graphical virt-manager application. The virsh command can be used in read-only mode by unprivileged users or, with root access, full administration functionality. The virsh command is ideal for scripting virtualization administration and provides many functions such as installing, listing, starting, and stopping virtual machines.
virt-manager
virt-manager is a graphical desktop tool for managing virtual machines. It allows access to graphical guest consoles and can be used to perform virtualization administration,virtual machine creation, migration, and configuration tasks. The ability to view virtual machines, host statistics, device information and performance graphs is also provided. The local hypervisor and remote hypervisors can be managed through a single interface.