Lecture 03 Introduction To Compute Virtualization - Part 2
Lecture 03 Introduction To Compute Virtualization - Part 2
Virtualization – Part 2
Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Foreword
Page 1 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Objectives
Page 2 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Introduction to Virtualization
CPU Virtualization
Memory Virtualization
I/O Virtualization
Page 3 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
I/O Virtualization
⚫ However, I/O devices are limited. I/O device sharing among multiple VMs requires
VMM. VMM intercepts access requests from VMs to I/O devices, simulates I/O
devices using software, and responds to I/O requests. This way, multiple VMs can
access I/O resources concurrently.
Page 4 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
I/O Virtualization
Paravirtualization,
Hardware-assisted virtualization
Page 5 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
I/O Virtualization
⚫ VMM virtualizes I/O devices for VMs. When a VM initiates an I/O request to an I/O
device, VMM intercepts the request sent by the VM, and then sends the real
access request to the physical device for processing.
⚫ No matter which type of OS is used by the VM, the OS does not need to be
modified for I/O virtualization.
Page 6 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
I/O Virtualization
⚫ VMM needs to intercept I/O requests delivered by each VM in real time and
emulates the request to a real I/O device. Real-time monitoring and emulation are
implemented by software programs on the CPU, which causes severe
performance loss to the server.
⚫ Complete simulation of the hardware, for example, keyboard and mouse. Access
to such hardware depends on the capture of focus by the host, and leads to poor
performance in some cases.
Page 7 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
I/O Virtualization
⚫ Paravirtualization:
⚫ Access to hardware drivers is transferred from the I/O frontend to the I/O backend.
This mode is usually only used for hard disks and Network Interface Cards
(NICs) and delivers high performance.
Page 8 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
I/O Virtualization
⚫ Front-End:
⚫ Back-End:
Device implementation
Page 9 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
I/O Virtualization
⚫ Paravirtualization:
⚫ This reduces the performance loss of VMM and therefore delivers better I/O
performance.. However, the VM OS needs to be modified (usually Linux).
Specifically, the I/O request processing method of the OS needs to be changed
so that all the I/O requests can be sent to the privileged VM for processing.
⚫ Guest uses specialized driver for optimized virtual hardware. Drivers must be
implemented for each type of OS.
Page 10 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
I/O Virtualization
⚫ Therefore, the time required for a VM to access the I/O hardware is the same as
that for a traditional PC to access the I/O hardware.
Page 11 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
I/O Virtualization
Page 12 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
I/O Virtualization
Page 13 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
I/O Virtualization
⚫ I/O Virtualization:
⚫ Paravirtualization
⚫ IO-through
Page 14 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Cloud Computing and Virtualization
Cloud
Computing
Page 15 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Cloud Computing and Virtualization
Page 16 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Cloud Computing and Virtualization
⚫ Cloud computing is a business model that provides users with IT services anytime
anywhere. Virtualization is an important technical means for cloud computing
implementation.
Page 17 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Cloud Computing and Virtualization
⚫ Open-source technologies are free of charge and can be used anytime. Users can
customize some special requirements based on open-source code. Once a
problem occurs in the system, the system recovery strongly relies on the
administrator's skillset and experience.
Page 18 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Mainstream Compute Virtualization
Technologies
Compute Virtualization
CPU virtualization, memory virtualization,
I/O virtualization
KVM Hyper-V
Huawei
FusionSphere
Page 19 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
What’s KVM?
Page 20 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
What’s KVM?
QEMU QEMU
KVM
Linux
HW Drivers
Hardware
Page 21 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
What’s KVM?
⚫ After the KVM module is installed in a common Linux OS, three running modes are
added:
Guest Mode: VMs, including their CPUs, memory, and disks, run in a restricted
CPU mode.
User Mode: The quick emulator (QEMU) typically runs in this mode. QEMU
emulates I/O requests.
Kernel Mode: In this mode, the hardware can be operated. When the guest OS
executes an I/O operation or privileged instruction, a request needs to be
submitted to the user mode, and then the user mode initiates a hardware
operation request to the kernel mode again to operate the hardware.
Page 22 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
What’s KVM?
VM VM
Application program A Application program B
Binaries/Libraries Binaries/Libraries
User
Guest OS Guest OS
Space User
ProcessesSpace QEMU QEMU
Processes
User space
Kernel space
KVM
Linux kernel
module
Physical
hardware
Page 23 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
KVM Architecture
⚫ Actually, QEMU is interacting with hardware. This means that all interactions with
the hardware need to pass through QEMU. Therefore, the simulation
performance delivered by QEMU is low. QMEU is able to simulate CPUs and
memory. In KVM, only QEMU is used to simulate I/O devices.
Page 24 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
KVM Architecture
⚫ The KVM kernel module is the core of a KVM VM. This module initializes the CPU
hardware, enables the virtualization mode, runs the guest machine in the VM mode,
and supports the running of the virtual client.
⚫ However, a VM requires other I/O devices such as Network Interface Cards (NICs)
and hard disks besides CPUs and memory. QEMU is required to implement other
virtualization functions.
⚫ Therefore, the KVM kernel module and QEMU form a complete virtualization
technology.
Page 25 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
KVM I/O Process - Default
Guest OS
4
I/O Shared Page 1 10
QEMU I/O 7 Device
Emulation Code
Driver
3 8
Notification 2 9
I/O Trap
5 Code
KVM Module
Linux Kernel
Device
Driver
Physical Hardware
Page 26 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
KVM I/O Process - Default
2. I/O Trap Code (I/O capture program) in the KVM module captures the I/O
operation request, performs corresponding processing, and then puts the processed
request into the I/O shared page.
3. The KVM module notifies QEMU that a new I/O operation request is placed in the
shared page.
4. After receiving the notification, QEMU obtains the detailed information about the
I/O operation request from the shared page.
Page 27 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
KVM I/O Process - Default
5. QEMU simulates the request and calls the device driver running in kernel mode
based on the request information to perform the real I/O operation.
6. The I/O operation is then performed on physical hardware through the device
driver.
7. QEMU returns the operation result to the shared page and notifies the KVM
module that the I/O operation is complete.
8. I/O Trap Code reads the returned result from the shared page.
10. The VM returns the result to the application that initiated the operation.
Page 28 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
KVM I/O Process - Virtio
⚫ In steps 2, 3, and 7 (Default) , KVM does not make any modification on the I/O
operation except for capturing the request and sending the notification.
Page 29 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
KVM I/O Process - Virtio
Guest OS
QEMU
1 8
3 2
Virtio Backend Virtio Frontend
Driver vring Driver
6 7
Notification
I/O Trap
4 Code
KVM Module
Linux Kernel
Device Driver
Physical Hardware
Page 30 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
KVM I/O Process - Virtio
2. The I/O operation request is not captured by the I/O capture program.
Instead, the request is stored in the ring buffer between the frontend and
backend drivers. At the same time, the KVM module notifies the backend
driver.
3. QEMU obtains the detailed information about the operation request from
the ring buffer.
Page 31 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
KVM I/O Process - Virtio
4. The backend driver directly calls the actual physical device driver to perform the
I/O operation.
6. QEMU returns the operation result to the ring buffer, and the KVM module notifies
the frontend driver.
7. The frontend driver obtains the operation result from the ring buffer.
8. The frontend driver returns the result to the application that initiated the
operation.
Page 32 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
KVM I/O Process - Virtio
Reduces the number of I/O request paths and improves the performance of
virtualization devices.
⚫ Virtio has some disadvantages. For example, some old or uncommon devices
cannot use Virtio but can only use QEMU.
Page 33 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
KVM Architecture
Management Tools
Virt-
Virsh Virt-viewer Virt-install Others
manager
Libvirt
A KVM system consists of three parts: KVM
kernel module, QEMU, and management
tool.
Linux Kernel
(KVM module)
QEMU QEMU
Guest Guest
OS OS
Page 34 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
KVM Architecture
Libvirt
VM VM VM VM
(Guest OS) (Guest OS) (Guest OS) (Guest OS)
Manage
-ment
Hypervisor Hypervisor Tools Hypervisor
Libvirt
Linux host Linux host
Node Node
Page 35 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
KVM Architecture
Libvirt
⚫ In cloud computing, there are various hypervisors. Each hypervisor has its own
parameters that are complex and difficult to use. Hypervisors are not unified, and
there is no unified programming interface to manage them, which severely affects
the cloud computing environment.
⚫ With Libvirt, it can connect to various hypervisors, such as KVM and Xen, and
provide APIs in various languages. Libvirt serves as the middle layer between the
management tool and hypervisor and is completely transparent to upper-layer
users.
Page 36 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
The Xen Hypervisor Approach
Page 37 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
The Xen Hypervisor Approach
⚫ Xen is a type 1 hypervisor that runs directly on the system hardware. Xen inserts a
virtualization layer between the system hardware and the virtual machines, turning
the system hardware into a pool of logical computing resources that Xen can
dynamically allocate to any guest operating system.
⚫ The operating systems running in virtual machines (Guest OS) interact with the
virtual resources as if they were physical resources.
Page 38 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
The Xen Hypervisor Approach
⚫ This is probably done by removing the performance loss while executing the
instructions requiring significant handling and by modifying portion of the guest
operating system executed by Xen, with reference to the execution of such
instructions.
Page 39 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
The Xen Hypervisor Approach
⚫ The guest OS asks the hypervisor to perform functions that would normally
require direct access to hardware: e.g., accessing certain CPU registers, etc. It is
much easier for the hypervisor to translate these calls instead in case of full
virtualization that emulates hardware devices and network interfaces to guests.
Page 40 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
The Xen Hypervisor Approach
⚫ Xen does not provide any device drivers. It has no direct knowledge of networking,
external storage devices, video, or any other common I/O functions found on a
computing system. But provides a mechanism by which a guest operating system
can be given direct access to a physical device.
So that Xen can replace the operating system as the most privileged software.
Xen contains a set of paravirtualized (PV) drivers that the guest loads instead of
the actual hardware drivers. So that Xen can use more efficient interfaces (such
as virtual network interfaces) to emulate devices — this increases performance.
Page 41 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Components of the Xen hypervisor
⚫ When Xen is first installed, it automatically creates the first domain, a special
domain known as Domain 0 (or dom0), is responsible for controlling the
hypervisor and starting other guest operating systems. It is a privileged domain
that can access the hardware resources and can manage all the other domains
(e.g., create, destroy, save, restore, etc.)
⚫ Other guest operating systems are called DomUs domain, where the U stands
for unprivileged. This is because they cannot control the hypervisor or start/stop
other domains.
Page 42 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
The Xen Architecture
PV
Backends
HW PV PV PV
Drivers Frontends Frontends Frontends
Xen
Hardware
Page 43 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Xen Terminologies
• Host: The system that provides the environment for running virtual machines.
• PVM: Paravirtualized Virtual machine where the Xen domains can only run
modified operating systems.
• HVM: Hardware Virtual Machine where the Xen domains can run unmodified
operating systems such as Microsoft Windows leveraging special virtualization
hardware
Page 44 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Components of the Xen hypervisor
Dom0 is a privileged domain with direct access to the hardware. It has exclusive
privileges to access the Xen hypervisor and manage all aspects of Guests.
Dom0 handles all access to the hardware and I/O and manages them on behalf
of the users’ VMs. This is because the hypervisor doesn’t contain device
drivers. Dom0 then shares these resources with guest operating systems.
The OS running on dom0 has the device drivers and performs I/O operations
on behalf of unprivileged guest domains (domU);
Page 45 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Components of the Xen hypervisor
Page 46 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Components of the Xen hypervisor
2) Frontend: driver within the guest domain, which allows the guest OS to access
the virtual device.
⚫ The backend and frontend use a high-speed software interface based on shared
memory to transfer data between the guest and dom0.
Page 47 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
The Xen approach
• Two drivers are included in Domain 0 to attend requests from Domain UPV or HVM guests
to Access physical I/O devices.
• The Domain U HVM Guest is a native OS with no notion of virtualization (sharing CPU time
and other VMs running). An unmodified OS doesn’t support the Xen split device driver,
Xen emulates devices by borrowing code from QEMU
Domain 0
PV Communicates directly with the local
networking hardware to process all virtual
Network backend
machines requests
driver
Communicates with the local storage disk to
Block backend driver
read and write data from the drive based
upon Domain U requests
HVM
Supports HVM Guests for networking and
Qemu-DM
disk access requests
Page 48 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
The Xen approach
• Domain UPV has access to hardware through front-end drivers using the split device
driver model.
• Shared memory is used for the communication between a domU and dom0
Domain U - PV
Similar to a registry
Console driver
Page 49 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Xen vs. KVM
⚫ In open-source virtualization technologies, Xen is on a par with KVM. KVM is full
virtualization, while Xen supports both paravirtualization and full virtualization. KVM, a
module in the Linux kernel, is used to virtualize CPUs and memory. It is a process of the
Linux OS.
⚫ Different from KVM, Xen directly runs on hardware, and VMs run on Xen.
⚫ VMs in Xen are classified as the privileged VM (Domain 0) that has the permission to
directly access hardware and manage other VMs (for example, Domain U). Domain 0 must
be started before other VMs. Domain U is a common VM and cannot directly access
hardware resources.
Page 50 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Xen vs. KVM Architecture
Page 51 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Xen vs. KVM (I\O Process)
Page 52 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Summary
Page 53 Copyright © 2019 Huawei Technologies Co., Ltd. All rights reserved.
Thank You
www.huawei.com