Kvm Basic Principle 1

Source: Internet
Author: User

Kvm Basic Principle 1

KVM is a Virtual Machine based on the Linux Kernel ). Adding KVM to the Linux kernel is an important milestone in the development of Linux, which is also the first virtualization technology integrated into the Linux main kernel. In the KVM model, each virtual machine is a standard process managed by the Linux scheduler. You can start the client operating system in the user space. A common Linux Process has two operating modes: kernel and user. KVM adds the third mode: Customer mode (with its own kernel and user mode ).

KVM is used to convert the Linux kernel into a system administrator by simply loading the kernel module. This kernel module exports a device named/dev/kvm, which can enable the kernel customer mode (except the traditional kernel mode and user mode ). With the/dev/kvm device, the VM makes its address space independent from the address space of the kernel or any other VM running. Devices in the Device Tree (/dev) are common to all user space processes. However, each process that opens/dev/kvm sees different mappings (to support isolation between VMS ). After KVM is installed, you can start your operating system in the user space. Each customer's operating system is a single process of the host operating system (or System Management Program. The figure shows a view that uses KVM for virtualization.

 
KVM then converts the Linux kernel into a System Management Program (when the kvm kernel module is installed ). Because the standard Linux kernel is a system management program, it will benefit a lot from the modifications to the standard kernel (memory support, scheduling program, etc ). Optimizing these Linux components (such as the new scheduler in the 2.6 kernel) can benefit both the System Management Program (host operating system) and the Linux client operating system. But KVM is not the first program to do this. UML has long ago converted the Linux kernel into a system management program. Using the kernel as a system management program, you can start other operating systems, such as another Linux kernel or Windows system.
After KVM is installed, the customer's operating system can be started in the user space. Each customer's operating system is a single process of the host operating system (or System Management Program. The figure shows a view that uses KVM for virtualization. The bottom is a hardware platform capable of Virtualization (currently referred to as an Intel VT or AMD-SVM processor ). On bare hardware, a System Management Program (Linux kernel with KVM module) is run ). This system administrator program is similar to a common Linux kernel that can run other applications. However, this kernel also supports the client operating system loaded using the kvm tool. Finally, the customer's operating system can support the same applications supported by the host operating system.

KVM is only part of the virtualization solution. The processor directly provides virtualization support (multiple operating system virtualization processors can be provided ). The memory can be virtualized through kvm. Finally, I/O is virtualized through a slightly modified QEMU process that executes a copy of each client's operating system process.
KVM introduces a new process mode in addition to the existing kernel and user mode to Linux. This new mode is called the customer mode. As its name suggests, it is used to execute the customer's operating system code (at least part of the Code ). Recall that the kernel mode represents the privileged mode of code execution, while the user mode represents the non-privileged mode (used for programs running outside the kernel ). Based on the running content and purpose, the execution mode can be defined for different purposes. The customer mode is used to execute the user's operating system code, but only for non-I/O Code. There are two standard modes in the customer mode. Therefore, the customer's operating system can support standard kernels in the customer mode, in user mode, you can run your own kernel and user space applications. The user mode of the customer's operating system can be used to perform I/O operations, which are managed separately.
The execution of I/O functions on the customer's operating system is provided by QEMU. QEMU is a platform virtualization solution that allows you to virtualize a complete PC environment (including disks, graphic adapters, and network devices ). Any I/O requests generated by the customer's operating system will be intercepted midway through and re-sent to the user mode simulated by the QEMU process.

KVM provides memory virtualization through/dev/kvm devices. Each customer's operating system has its own address space, which is mapped when the customer's operating system is instantiated. The physical memory mapped to the customer's operating system is actually the virtual memory mapped to the process. To support the conversion from a customer's physical address to a host's physical address, the system maintains a set of shadow page tables ). The processor can also use the System Management Program (host kernel) to support the memory conversion process when accessing unmapped memory locations.
Operating System of new customers by instance
The new customer's operating system is instantiated by a tool named kvm. This tool can work with the kvm module to use/dev/kvm to load the customer's operating system and associate it with a virtual disk (a common file in the host operating system, then start the customer's operating system.
A set of ioctls executed on/dev/kvm devices can provide control support. When this special file is opened for the first time, a new VM object is created, which is associated with a virtual CPU. You can then use several ioctls to create a virtual CPU, check the kvm version, create a memory area, and then start a virtual CPU. You can use the kvm command to implement this function.

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.