We succeeded in running the KVM, with some perceptual knowledge, which is very important for beginners. But not enough, we have to know some of the KVM implementation mechanism, which will be helpful for future work.
CPU Virtualization
KVM virtualization requires CPU hardware support. Remember that we spoke in the previous section using commands to see if the CPU supports KVM virtualization?
[Email protected]:~# egrep-o ' (VMX|SVM) '/PROC/CPUINFOVMX
If there is output VMX or SVM, then the current CPU supports KVM. CPU Vendors Intel and AMD both support virtualization, unless it is a very old CPU.
A KVM virtual machine is actually a QEMU-KVM process in the host, and is dispatched just like any other Linux process. For example, in my experiment machine running on the virtual machine kvm1 in the host in the PS can see the corresponding process.
Each virtual Vcpus in the VM corresponds to a thread in the QEMU-KVM process. See
In this example, the host has two physical CPUs, up to two VMs VM1 and VM2. VM1 has two vcpu,vm2 with 4 Vcpus. You can see that VM1 and VM2 have two and 4 threads scheduled on two physical CPUs, respectively.
Another point of knowledge is shown here that the total number of Vcpus in a virtual machine can exceed the number of physical CPUs, which is called CPU overcommit (over-provisioning). KVM allows Overcommit, a feature that allows VMs to take full advantage of the host's CPU resources, but only if at the same time not all VMS are running at full capacity. Of course, if each VM is very busy, but it will affect the overall performance, so when using overcommit, you need to understand the load of the virtual machine, need to test.
Memory Virtualization
KVM shares physical system memory through memory virtualization and is dynamically allocated to virtual machines. See
In order to run multiple virtual machines on a single machine, KVM requires a direct address translation of the PA (physical memory)---MA (machine memory), which is VA (virtual memory). The VM OS controls the mapping of the virtual address to the physical address of the client's memory (VA-PA), but the virtual machine OS does not have direct access to the actual machine memory, so KVM is responsible for mapping the client's physical memory to the actual machine memory (PA-to-MA). Concrete implementation will not do too much introduction, we are interested to check the information.
There is also a point to remind you that memory is also overcommit, that is, all the memory of the virtual machine can exceed the host's physical memory. However, it is also necessary to be fully tested, otherwise performance will be affected.
In the next section we discuss how KVM implements storage virtualization.
The principle of CPU and memory virtualization-5 minutes a day to play with OpenStack (6)