Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is KVM Virtualization

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "what is KVM Virtualization". In daily operation, I believe many people have doubts about what KVM Virtualization is. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "what is KVM Virtualization?" Next, please follow the editor to study!

Introduction to KVM Virtualization

1. Virtualization is divided into full virtualization and semi-virtualization, which needs the support of CPU.

2. Full virtualization: no configuration is required to make users feel like a real server

3. Semi-virtual machine: user configuration is required, which is a bit troublesome.

4. KVM is just a module of the Linux kernel. More assistive tools are needed to manage and create complete KVM virtual machines.

5. Compared with Xen, KVM is much simpler. It doesn't need to recompile the kernel or make any changes to the current kernel, it's just a few .ko modules that can be loaded dynamically. It has a more compact structure and less code. As a result, mistakes are less likely. And in some ways, performance is better than Xen.

6. / etc/libvirt/qemu directory, which stores the configuration files of the virtual machine.

7. Backup of kvm: copy the xml configuration file in the / etc/libvirt/qemu directory and the img file set in xml.

8. Restore kvm: enter virsh, execute the path of the xml file in the define directory, and ensure the existence of the image file.

Virsh # define / etc/libvirt/qemu/winxp.xml

9. KVM allows the client to overload the use of (over-commit) physical resources, that is, the amount of CPU and memory allocated to the client is more than physically existing resources.

10. The overloaded use of CPU means that the total number of vCPU used by one or more clients exceeds the actual number of physical CPU. QEMU will start more threads to serve the client, and these threads are also scheduled to run on the physical CPU hardware by the Linux kernel.

11. The most recommended practice is to use over-commit for multiple single CPU clients. For example, in a host with 4 logical CPU, more than 4 clients (such as 8, 16) are running at the same time, each of which is assigned a vCPU. At this time, if the load of each host is not very large, the scheduling of the host Linux for each client is very effective, and such overload use will not cause performance loss in the client.

12. The least recommended practice is to have a client's number of vCPU exceed the number of physical CPU. For example, in a host with four logical CPU, one or more clients are running at the same time, and each client has more than 4 vCPU (for example, 16). This method of use can lead to a significant performance degradation, which is not as good as assigning 2 (or 4) vCPU to the client, and may make the entire system unstable if the client is overloaded. However, when the load is not 100% full, there is no significant performance penalty for one (or more) clients with 4 vCPU running on a host with 4 logical CPU.

13. In general, KVM allows overload use of CPU, but it is not recommended that CPU be overloaded in actual production environments, especially in heavily loaded environments. With CPU overloaded in a production environment, it is necessary to conduct rigorous performance and stability tests before deployment.

14. Memory in KVM also allows over-commit, and KVM allows the total amount of memory allocated to the client to be greater than the actual total amount of physical memory available.

15. In general, there are three ways to achieve memory overload:

(1) memory swap (swapping): use swap space (swap space) to make up for the lack of memory.

(2) ballooning: the cooperation between the host Hypervisor and the client is realized through the virio_balloon driver.

(3) Page sharing (page sharing): merge the same memory pages used by multiple client processes through KSM (Kernel Samepage Merging).

Of these, the first method of memory swapping is the most mature (it was used very early in Linux), but virtual memory swap is not recommended.

16. KVM (module):

The modprobe command loads the KVM module, and if you install the KVM package with RPM, the system loads the module automatically at startup. After the module is loaded, you can further create the virtual machine through other tools. But the KVM module is far from enough, because the user cannot directly control the kernel module to do things, and there must be a user-space tool.

17. QEMU (management tools):

QEMU is a powerful virtualization software that can virtualize different CPU architectures. For example, virtualize a Power CPU on x86 CPU and use it to compile a program that can run on Power.

18. QEMU-KVM (management tools):

KVM uses the x86-based part of QEMU and slightly modifies it to form a user-space tool QEMU-KVM that can control the KVM kernel module. So the Linux distribution is divided into KVM kernel modules and QEMU-KVM tools in the kernel part.

19. Libvirt, virsh, virt-manager (management tools):

RedHat has developed more assistive tools for KVM, such as libvirt, libguestfs, etc. The reason is that QEMU tools are inefficient and not easy to use. Libvirt is a set of API that provides multiple language interfaces and provides a convenient and reliable programming interface for various virtualization tools. It supports not only KVM but also other virtual machines such as Xen. With libvirt, you only need to connect to the KVM or Xen host through the functions provided by libvirt, and you can control different virtual machines with the same command. Libvirt not only provides API, but also comes with a set of text-based commands for managing virtual machines, virsh. You can use all the functions of libvirt by using the virsh command. But what end users want more is a graphical user interface, which is virt-manager. It is a set of virtual machine management graphical interface written in python, through which users can intuitively operate different virtual machines. Virt-manager is implemented using libvirt's API.

In the KVM model, each virtual machine is a standard process managed by the Linux scheduler, and you can start the client operating system in user space. A normal Linux process runs in two modes: the kernel and the user. KVM adds a third mode: client mode (with its own kernel and user mode).

The kernel module exports a device called / dev/kvm, which enables the client mode of the kernel (except for traditional kernel mode and user mode). With the / dev/kvm device, VM makes its address space independent of the kernel or any other VM running.

At this point, the study of "what is KVM Virtualization" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report