First, there are two types of implementations of virtualization technology, as follows:
Type-I:
hypervisor --> vm
Type-II:
host --> vmm --> vms
In fact, this matches the two current mainstream virtualization technologies, namely Xen and KVM,
Xen:
hypervisor, Dom0
KVM:
Kernel-based Virtual Machine
This article will start with KVM and record the components, features and implementation of KVM.
KVM features:
Memory management:
Swap the memory allocated to the vm to swap
Support using Huge Page
Supports memory address mapping using Intel EPT or AMD RVI technology: GVA-->GPA-->HPA
支持KSM(Kernel Same-page Merging)
Hardware Support:
Depends on the Linux kernel
storage:
local storage
network attached storage
storage area network
Distributed storage such as GlusterFS
Live Migration:
Supported GuestOS:
Linux,Windows,OpenBSD,FreeBSD,OpenSolaris
Device driver:
Full virtualization of IO devices: emulating hardware
Paravirtualization of IO devices: Install the driver in GuestOS: virtio
virtio-blk, virtio-net, virtio-pci, virtio-console, virtio-ballon
KVM limitations:
General limitations:
CPU overcommit:
Time recording is difficult to be precise and depends on the time synchronization mechanism
MAC address:
When the number of VMs is particularly large, there is a possibility of conflict
Live migration
performance limitations
The operating mode of the system after the KVM module is loaded:
Kernel mode: GuestOS performs I/O operations, or other special instruction operations are operated by the kernel. Called "guest-kernel" mode.
User mode: Requests I/O operations on behalf of the GuestOS.
Guest mode: The non-I/O operation of GuestOS, in fact, it is more aptly called the user mode of the virtual machine. Called "guest-user" mode.
Components of KVM:
Two types of components:
/dev/kvm: Works on the hypervisor. In user space, management functions such as VM creation and startup can be completed through the ioctl() system call: it is a character device.
Function: You can create VMs, allocate memory for VMs, read and write registers of vcpus, inject interrupts into vcpus, run vcpus, and more.
The qemu process: works in the user space and is mainly used to implement IO devices that simulate PCs.
KVM tool stack:
qemu:
qemu-kvm
qemu-img
libvirt:
GUI: virt-manager, virt-viewer
CLI: virt-install, vrish
QEMU mainly uses the following parts:
processor simulator
Emulate IO devices
Associate a simulated device to a real device
Debugger
User interface for interacting with the simulator
Installation of KVM on CentOS 6.5:
1. First confirm whether the CPU supports HVM
grep -E --color=auto "(vmx|svm)" /proc/cpuinfo
2. Load the module
modprobe sqm
modprobe sqm-intel
3. Verify
ll /dev/kvm
Since KVM has been incorporated into the Linux kernel since version 2.6.20, it is very simple to install KVM, but to use KVM for virtual machine management, you also need to install KVM management tools.