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

How to use KVM of QEMU in Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

It is believed that many inexperienced people have no idea about how to use the KVM of QEMU in Linux. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

QEMU is a powerful virtual machine software, which can completely simulate all the hardware needed by a complete computer in the form of software, even hardware of different architectures. On these virtual hardware, a complete operating system can be installed. The operation mode of QEMU is shown below:

Obviously, although the function is powerful in the form of software simulation hardware, the performance is difficult to meet the needs of users. The performance of the simulated hardware is bound to be greatly reduced compared with that of the physical hardware. In order to improve the performance of virtual machine software, developers show their own talents. Among them, the most commonly used method is to open a hole in the main operating system through the kernel module, through which the operations in the virtual machine are directly mapped to the physical hardware, so as to improve the performance of the operating system running in the virtual machine. As shown below:

Among them, KVM is a typical representative of this acceleration mode. KVM and Xen are often compared in the community, but they are actually completely different. As can be seen from the above figure, using the kernel module acceleration mode, the main operating system is still dominant, and the kernel module only makes a hole in the main operating system to connect the virtual machine and physical hardware to accelerate the virtual machine. However, the guest operating system in the virtual machine is still very limited. This mode is more suitable for desktop users, the main operating system is still their main battlefield, whether office or playing games, are completed through the main operating system, the guest operating system is only used on demand. As for Xen, it uses a completely different concept, which is more suitable for enterprise users, so desktop users should not touch it easily. I'll talk about it in the next article.

In fact, VirtualBox also adopts this mode of kernel module acceleration. I say this because when you install VirtualBox, it requires DKMS to be installed. As shown below:

People familiar with Linux know that DKMS exists to make it easy for users to manage kernel modules, and people who are not familiar with DKMS can get a general idea of Google. About the specific use of VirtualBox, I will talk about it in the next article. This article is mainly about KVM.

KVM and QEMU are complementary, QEMU can use the KVM kernel module to accelerate, while KVM needs to run the virtual machine using QEMU. As you can see from the figure above, if you want to install KVM using Ubuntu's package management software, you are actually installing qemu-kvm. Qemu-kvm is not a very complex software package, it contains only a few files, as shown in the following figure:

Looking at its documentation with the man command, it is found that not only does the qemu-kvm package contain few files, but its executable file, kvm, is just a simple wrapper of the qemu-system-x86_64 command, as shown below:

So the question is, which package does the kvm kernel module come from? In fact, kvm has been added to the kernel since Linux 2.6. If you have to find out which package provides the kvm kernel module kvm.ko, you can check it out with the following command:

At this point, you can see that the use of KVM is very simple. Next, I'll use KVM to run the WinXP operating system installed in the previous article to experience the efficiency of QEMU accelerated by KVM. Run QEMU accelerated with KVM using the following command:

As you can see, after using KVM acceleration, the WinXP in the virtual machine runs much faster, and it only takes 34 seconds to boot. I adjusted the resolution to 1366 to 768, and the graphical interface ran smoothly. There was no problem opening the IE browser or Office office software, and there was no further surge in CPU usage to 100%. If you check it with the ps-ef | grep qemu command, it is found that the kvm command is still running the qemu-system-x86_64 program, except that the-enable-kvm parameter is added, as shown below:

In addition, it is also important for desktop users to have a good graphical interface. Although QEMU and KVM themselves do not have a graphical interface for the virtual machine manager, we can use third-party software, such as virt-manager. You only need to use sudo apt-get install virt-manager to install the software. The software relies on libvirt and is automatically installed during installation. The effect of running virt-manager is shown below. Note that it must be run using sudo, because the software requires superuser permissions:

The software can automatically identify whether the virtual machine environment in the system is QEMU+KVM or Xen. Create a new virtual machine, because you have previously installed a WinXP system, so choose to import an existing hard disk image. After clicking next, the following interface appears:

There is nothing to say about this step. Click on the next step, as shown in the following figure:

You can set network options here. If you check "customize configuration before installation", you can further customize the hardware, as shown below:

In the figure above, we can see all the types of virtual graphics cards supported by the virtual machine. Here, of course, I chose VMVGA, because I used to use VMWare a lot and knew that these operating systems worked well under the virtual graphics card settings of VMWare. Of course, you can try all the other options, but you need to install the corresponding driver in the virtual operating system.

Finally, the effect of the virtual machine running is as follows:

As you can see, the interface provided by the program has a very rich function menu, and the function is so powerful that it can even send combined keys to the operating system in the virtual machine.

It can be said that if there is no VirtualBox, the combination of QEMU+KVM should be the first choice for desktop users.

After reading the above, have you mastered how to use the KVM of QEMU in Linux? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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