Hacking Book | Free Online Hacking Learning

Home

introduction to virtualization technology

Posted by forbes at 2020-03-11
all

Reading: 3178

Virtualization technology first appeared in IBM mainframe system in 1960s, and gradually became popular in system 370 Series in 1970s. Virtualization refers to the operation of computer components on the basis of virtual rather than real.

Virtualization technology can expand the capacity of hardware and simplify the process of software reconfiguration. The virtualization technology of CPU can simulate the parallel of multiple CPUs with a single CPU, allowing a platform to run multiple operating systems at the same time, and applications can run in independent space without affecting each other, thus significantly improving the working efficiency of the computer.

Advantages of virtualization

Reduce operation cost, accelerate application deployment, improve service availability, improve resource utilization, dynamically schedule resources and reduce energy consumption

Virtualization mode

Full Virtualization:

Also known as hardware assisted virtualization technology, the initial virtualization technology is full virtualization technology, which adds a software layer between the virtual machine (VM) and the hardware - hypervisor, or virtual machine manager (VMM). It is mainly to capture and process the privileged instructions sensitive to virtualization between the client operating system and hardware, so that the client operating system can run without modification, and the speed will vary according to different implementations, but roughly meet the needs of users. This mode is the most mature and common in the industry, and it belongs to hosted mode and hypervisor mode. Famous products include IBM CP / CMS, VirtualBox, KVM, VMware Workstation and VMware ESX. The advantage of full virtualization is that all the hardware needed by the virtual machine is generated by the virtual system, and the operating system running on the virtual machine does not need to be modified. The only limitation is that the operating system must be able to support the underlying hardware. However, the current operating system generally supports the underlying hardware, so it is not a limitation.

Semi Virtualization:

Paravirtualization is a new technology, also called quasi virtualization technology. It modifies the client's operating system and adds special APIs to optimize the instructions sent by the client's operating system on the basis of full virtualization, so that guest OS can cooperate with hyperivosr to realize virtualization very well. In this way, there is no need to recompile or capture privileged instructions, making its performance very close to the physical machine. The most classic product is Xen, and because Microsoft's Hyper-V technology is similar to Xen, it can also be attributed to semi virtualization. The virtualization system only provides the virtualization capability of the CPU, and other hardware devices share with the real machine, so the efficiency of using hardware devices is better. The disadvantage is to modify the operating system containing the API, but for some operating systems (mainly windows) without the API, this method cannot be used. Compared with full virtualization, the architecture of this model is simpler and has certain advantages in overall speed. However, the guest OS needs to be modified, so it is troublesome in terms of user experience.

Two virtualization architectures

Hosted architecture and bare metal architecture, as shown.

Host architecture is to install and run virtualization programs on the operating system, which depends on the support of host operating system for devices and the management of physical resources;

Bare metal architecture is to install virtualization software directly on the hardware, and then install the operating system and Application on it, relying on the virtual layer core and server console for management.

Common virtualization technologies

1 KVM

KVM (kernel based virtual machine) is a kind of virtualization infrastructure used in Linux kernel. It is a full virtualization solution of Linux that hardware supports virtualization technology (Intel VT or AMD-V). KVM is a loadable module in Linux kernel. Its function is to transform Linux kernel into a hypervisor with bare metal architecture.

2 Xen

Xen is the first open-source virtualization engine, initially an open-source project of Cambridge University. Xen is a software layer running directly on the hardware, which can run multiple guest OS on the computer hardware at the same time.

3   VMware ESXi

VMware esxi is an enterprise virtualization product of VMware. It is a special operating system used to manage hardware resources, which can run directly on bare machines. The virtualization kernel (called vmkernel) is fully responsible for the management of hardware and virtual machines.

4   Microsoft Hyper-V

Hyper-V is a virtualization technology introduced by Microsoft, which is built into Windows Server 2008 for the first time. Like VMware esxi and Xen, it adopts bare metal architecture and runs directly on the hardware.

KVM and its surroundings

KVM introduction

KVM, the full name of which is kernel based virtual machine, was originally developed by qumranet, an Israeli company. KVM was incorporated into the Linux 2.6.20 kernel released in February 2007 in December 2006. After red hat acquired qumranet in September 2008, KVM was used as the default virtualization engine in RHEL 6 and later releases.

KVM is a Linux full virtualization solution with x86 architecture and hardware supporting virtualization technology (Intel VT or AMD-V). It includes a core module kvm.ko (kvm-intel.ko or kvm-amd.ko) that provides the underlying virtualization and can be loaded for the processor. KVM itself does not perform any hardware emulation, and the modified QEMU is required to provide it with simulated I / O.

KVM schema diagram

In KVM architecture, each virtual machine is actually a regular Linux process, which is scheduled by the Linux scheduler. Therefore, KVM uses all the functions of the Linux kernel. As shown in the figure, KVM is a module in Linux kernel. User space provides BIOS, PCI bus, USB bus and a set of standard devices (such as IDE, SCSI disk controller, network card, etc.) simulation by using modified QEMU.

Relationship between KVM and QEMU

QEMU is an open source simulator written by Fabrice bellard. QEMU can simulate a complete hardware environment, similar to Bochs and pearlpc, but with high speed, cross platform and other characteristics. Because QEMU is a pure software simulation, the instructions of guest OS need to be escaped to real hardware by QEMU, so the performance is poor.

KVM is only a kernel module, which can only provide the virtualization of CPU and memory. There is no user space management tool, so QEMU is needed to provide I / O support for KVM.

Qemu-kvm branch appeared in QEMU 1.0. After three official versions (1.1 / 1.2 / 1.3) were released, it was merged with QEMU main version. Therefore, QEMU now supports qemu-kvm by default.

The relationship between KVM and libvirt

Libvirt is a set of open-source API to realize Linux virtualization, which aims to provide a single way to manage a variety of different virtualization schemes. Libvirt consists of a set of API libraries, a libvirtd service, and a virsh command line management tool. Although libvirt is developed in C, it can well support mainstream programming languages, including C, python, Perl, Java, etc.

The latest release also includes a series of libvirt based tools to simplify the maintenance and management of virtual machines:

1. Virt install: a tool for creating virtual machines, which supports starting from local or network images (NFS, FTP, etc.).

2. Virsh: an interactive / batch shell tool, which can be used to complete the daily management of virtual machine.

3. Virt Manager: a general graphical management tool that can be used to manage local or remote hypervisors and their virtual machines.

Virt viewer: a lightweight graphics console tool that can connect to remote virtual machine safely.

KVM – QEMU – libvirt diagram

Introduction to KVM

How to use KVM

Common methods for creating KVM virtual machines:

Prepare disk image

Prepare the disk image of the virtual machine before creating the KVM virtual machine. Virtual machine image is used to simulate the hard disk of the virtual machine. Before starting the virtual machine, you need to create image files. There are two common methods:

1. Use QEMU img command to create virtual machine image:

qemu-img  create   -f   qcow2   tiny.qcow2   10G

Create a 10g image file in qcow2 format with the name of tiny.qcow2

2. Use the existing system image file to start the virtual machine directly as the hard disk image.

Create virtual machine

1 use QEMU KVM command to create virtual machine

2 create virtual machine with virt Manager

The easiest way to create a KVM virtual machine is to use the virt manager tool.

Start virt manager as root:

[[email protected] ~]#  virt-manager

In the virt Manager window, click "new" in the file menu, and create according to the prompts.

3 create virtual machine with virsh

When using the virsh tool to create a virtual machine, you need to prepare another XML configuration file. This XML file configures the virtual machine to be created in detail. For specific XML content and configuration methods, please refer to the relevant documents of libvirt. (http://libvirt.org/format.html)

Create virtual machine command:

[[email protected] ~]# virsh   create    tiny.xml

Tiny.xml defines the virtual machine configuration information to be created.

3 use Python to call libvirt interface to create virtual machine.

Libvirt provides libraries that support mainstream programming languages. This paper takes Python as an example to introduce the process of creating a virtual machine.

epilogue

This paper introduces the concept of virtualization and several virtualization technologies. For the KVM virtualization scheme recommended by Linux, this paper shows four ways to create KVM virtual machine. In general, the most convenient and fast way to manage KVM is to use libvirt. Virtualization is a wide range of topics. I hope this article can be the starting point for you to explore advanced topics and help you.

If you need to know more, you can join QQ group: 570982169 direct inquiry: 010-68438880