Linux virtualization Technology The relationship between KVM, Qemu and Libvirt

Source: Internet
Author: User

Description: As a personal understanding, KVM is a kernel virtualization technology, and the kernel is not used on the interface, then QEMU provides a user-level interface to assist each other. Of course, using QEMU alone can also be a complete set of virtual machines, but QEMU+KVM is basically the standard Linux virtual Machine management tool.

First, Introduction:

Mainly divided into three parts. The first part is the introduction of virtualization technology, the second part is the introduction of KVM, QEMU and Libvirt, the third part is the virtual introduction of network cards.

The first part:

This section is a brief summary and explanation of the virtual machine technology that exists in the current period, many of which are in the same sentence. In fact, every technology can be re-written a rich blog, but each technology is not the focus of this article, so do not discuss each technology in detail. Comments and corrections are welcome for each technology.

Virtualization Definition:

Virtualization primarily refers to special technologies that provide users with an abstract, unified, simulated computing environment (known as a virtual machine) by hiding the actual physical characteristics of a particular computing platform (IBM-defined). Virtualization provides technical support for the efficient use of mainframe resources. Virtual machine technology is also a variety of, but can be virtual level or virtual aspect is spread from the hardware to the application layer of the entire computer system. Shown in the film:

Virtual Machine Classification:

The classification of virtual machines is also varied. Can be divided into host-oriented virtual machines and virtual machines for bare metal, by whether they are deployed on bare metal. A host-oriented virtual machine is the installation of a virtual machine management (VMM) program on a host that already has an operating system installed, while a bare-metal installation of a hypervisor is directly installed on bare metal, and all virtual machine calls are handled directly by the hypervisor, without the operating system as a step, So this approach is more efficient than host-oriented. However, more popular technologies such as Vmware,xen are host-oriented.

Then according to the above diagram to classify, can be divided into the virtual hardware and the operating system or the virtual software. At the level of hardware virtualization, there are three different technologies:

1, full virtualization (fully virtualized), almost complete simulation of a set of real hardware equipment. Most operating systems can run directly in a fully virtualized environment without any modifications. Technologies like KVM are fully virtualized.

2. Partial virtualization (partial virtualization) provides only simulations of critical computing components or instruction sets. The operating system may need to make some modifications before it can be run in a partial virtualized environment.

3, paravirtualization (semi-virtualized), do not simulate hardware devices, virtual machines have a separate operating environment, through the hypervisor to share the underlying hardware resources. Most operating systems need to be modified to run in a semi-virtualized environment. It has a slightly higher performance than full virtualization. Like Xen. Because the kernel of the managed system needs to be changed, Xen does not support the win virtual machine.

There are also hardware-assisted virtualization, which is a host hardware architecture that provides support for virtualization to some extent. Such architectural support is provided by INTEL-VT and Amd-v, please refer to the resources given.

Software-level virtualization often refers to the provision of multiple isolated virtual operating environments on the basis of the same operating system instance, often referred to as container technology. LXC (Linux Container) adopts this technology, which mainly uses the technology provided by Linux itself to simulate virtualization to some extent. Software virtualization can also be understood as a process-level virtual machine, and other virtualization becomes a system-level virtual machine. Software that is responsible for virtualization in a process-level virtual machine becomes the runtime software, and the software that is responsible for virtualization in a system-level virtual machine becomes VMM (virtual machines Monitor)

For both hardware and software virtualization, there are advantages and disadvantages of the two technologies. For hardware virtualization, we discuss full virtualization and partial virtualization. Because most of the virtualization technology now Xen, KVM support both of these. Hardware virtualization is basically a virtual system on a host, and the virtual machines are invisible to each other. This will obviously result in a lot of duplicate threads and duplicate memory pages appearing, which will certainly have an impact on performance. So with this technique, there is a certain limit to the number of virtual machines on a single host.

For software virtualization, we discuss LXC, because it's the only one I've used. LXC is to isolate a thread through Cgroup, to restrict resources, and to isolate resources by namespace system calls to the calling system. LXC Introduction. It can also be seen that all of its virtualized virtual machines are running on the host itself, and its threads and resources are visible to the host. This does not have a lot of duplicate threads and memory problems, so a host can use this technology to virtual more virtual machines.

Recently very popular Docker is also a kind of software virtualization, it is the principle of using Linux provided by the namespace to isolate resources, but it provides more powerful than the LXC function implementation.

Part II:

This is part of the main introduction of the three components of the different functions, more details need to be supplemented, but also welcome comments to supplement, error correction.

KVM Introduction:

For KVM, it is a support for virtual machine technology and a functional module in the Linux kernel. It is supported in any Linux branch after Linux2.6.20. It also has a condition that the hardware requirements must meet a certain standard of hardware architecture. Both INTEL-VT and AMD-V are supported. For support or not, you can view it from the command line: Egrep ' (VMX|SVM) '--color=always/proc/cpuinfo. If there is any content, the hardware architecture of the period is supported by KVM, otherwise it is not supported. In addition, even if supported, but in the BIOS is the default setting does not turn on the feature, so you have to go to the BIOS set it to enable. When the settings are successful, you need to shut down again, and note that the shutdown is not a reboot. Otherwise, the change to this setting is not effective.

Qemu

What QEMU is. In fact, it is also a virtualization technology, even if you do not use KVM, only son Qemu can fully implement a virtual machine. Then why do you have the term QEMU-KVM? Because KVM technology is already quite mature and can isolate a lot of things, but in some ways it is impossible to actually make a virtual machine. For example, the virtual network card, that time requires additional technology to complement, and QEMU-KVM is such a technology. It complements the lack of KVM technology and optimizes KVM performance.

Libvirt

Libvirt is a thing again. It is a series of library functions provided for other technical calls to manage virtual machines on the machine. Including a variety of virtual machine technologies, KVM, Xen and LXC, can call the Libvirt provides the API to manage the virtual machine. With so much virtual machine technology, why does it provide so much management functionality that. Because of its design concept, it is a drive-oriented architecture design. Any kind of virtual machine technology is developed to design the driver relative to this technology. In this way, different virtual machine technologies can use different drivers, and they will not affect each other directly, so it is easy to expand. Furthermore, LIBVIRT provides a programming interface for multiple languages, which can be programmed directly to invoke the external interface provided by Libvirt to implement the operation of the virtual machine. The IaaS in today's popular cloud computing is very closely related to the library. The idea of architecture design can be seen through it.

As you can see from this graph, there are many driver on the Libvirt API, and there is a driver for each virtual machine technology to act as a wrapper between the virtual machine technology and the Libvirt. This design avoids the need for libvirt to design various interfaces for different virtual machine technologies, focusing primarily on the underlying implementation and providing external interface calls, while different virtual machine technologies do what they need by invoking the interface provided by Libvirt.

Part III:

This section focuses on how virtual machines are virtual, or how they are connected to the network.

The general Virtual Machine Virtual network Setup mainly includes three kinds of methods. Mainly as follows:

Nat Mode

Some people call this mode host (host) mode. In this mode the virtual machine can be understood as having no own independent NIC. All requests to access the virtual machine are sent directly to the host and then forwarded to the virtual machine by accessing the host. The corresponding virtual machine accesses other networks, which are forwarded to the host and then forwarded out. For a network other than a host, the virtual machine is not known to exist.

Bridge mode

Bridge mode is the use of more than one mode, it is the virtual machine has its own independent network card and IP, and then by borrowing the host's network card to connect externally. It treats the host's Nic as a bridge through which the world of the extranet is connected. In this mode, it can be easily understood that the virtual machine and the host is two different machines, with independent IP can access each other. For the IP acquisition of the virtual machine, it can be specified directly or obtained through DHCP.

Internal mode

This is to isolate the network between the virtual machine and the host network. Virtual machine is a network, the host is a network, each other can not access each other.

Second, the relationship:

KVM virtual machines are based on Linux kernel virtualization and are integrated into each major release of Linux since Linux2.6.20. It is managed using Linux's own scheduler, so its core source code is few compared to Xen. KVM Virtualization requires hardware support (such as Intel VT Technology or AMD V technology) and is hardware-based full virtualization. The early days of Xen were software-based simulations of para-virtualization, and the new version was full virtualization based on hardware support.

QEMU is an analog processor, and now the most used is to combine KVM and QEMU.

To be exact, KVM is a module of the Linux kernel that can be loaded with command modprobe to load a KVM module. After the module is loaded, you can further create the virtual machine from the tool. But the KVM module alone is not enough. Because users cannot directly control the kernel to do things, they must also have a tool running in user space. This user-space tool, the KVM developer chooses the already formed open source virtualization software QEMU. It says QEMU is also a virtualization software. It is characterized by a virtual different CPU. For example, a power CPU can be virtualized on a x86 CPU, and it can be used to compile a CPU that can run on power and use it to compile programs that can run on power. KVM uses a subset of QEMU and is transformed into a user-space tool that can control KVM. So you'll see that the official KVM download has two (QEMU and KVM) three files (KVM modules, qemu tools, and a collection of both). That is, you can upgrade only the KVM module, or you can upgrade only the Qemu tool. This is the relationship between KVM and QEMU.

Such as:

Linux kernel-based virtual Machine (KVM) is a Linux open source virtualization software that is based on hardware virtualization extensions (Intel vt-x and Amd-v) and the modified version of QEMU. The KVM implementation module is two, namely: Kvm.ko is the infrastructure that provides core virtualization; processor-specific modules Kvm-intel.ko and Kvm-amd.ko. It is designed to support complete hardware simulations when multiple unchanged p operating systems need to be booted.

A common Linux process has two modes of operation: the kernel and the user. KVM adds a third mode: Customer mode (with its own kernel and user mode). In the KVM model, each virtual machine is a standard process that is managed by the Linux scheduler.

KVM consists of two parts: one is the device driver that manages the virtual hardware, the driver uses the character device/DEV/KVM as the management interface, and the other is the user space component that simulates the PC hardware, which is a slightly modified QEMU process.

Reference:

Virtmanager Introduction: http://virt-manager.org/

Popek and Goldberg virtualization requirements: Wiki Popek and Goldberg virtualization requirements

Linux Namespace Introduction: https://lwn.net/Articles/531114/

INTEL-VT Introduction: INTEL-VT Introduction

http://blog.csdn.net/zwan0518/article/details/10613481 (The above sections are transferred from this article)

Http://blog.chinaunix.net/uid-16361381-id-211999.html

http://blog.csdn.net/chdhust/article/details/7557791

Https://www.cnblogs.com/bakari/p/7858029.html

http://blog.csdn.net/chdhust/article/details/7557791 (The above sections are transferred from this article)

Linux Virtualization Technology KVM, QEMU and libvirt relationship (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.