Virtualization PART 2
Virtualization PART 2
Cloud Computing
(Introduction of Virtualization)
Virtualization Structures/Tools and Mechanisms
• In general, there are three typical classes of VM architecture. Figure showed
the architectures of a machine before and after virtualization.
• Before virtualization, the operating system manages the hardware.
• After virtualization, a virtualization layer is inserted between the hardware
and the operating system. In such a case, the virtualization layer is responsible
for converting portions of the real hardware into virtual hardware.
• Therefore, different operating systems such as Linux and Windows can run on
the same physical machine, simultaneously.
• Depending on the position of the virtualization layer, there are several classes
of VM architectures, namely the hypervisor architecture, para-virtualization,
and host-based virtualization.
• The hypervisor is also known as the VMM (Virtual Machine Monitor). They
both perform the same virtualization operations.
Why Virtualization ? - Green Focus
The Reality:
• Most servers only use 5-15% of their capabilities on average, while
consuming 60-90% of their peak power.
Hardware
• E.g.: VMware uses a
combination of direct execution
and binary translation techniques
to achieve full virtualization of
CPU Memory NIC DISK server systems.
44
Binary Translation of Guest OS Requests
Using a VMM
This approach was implemented by VMware and
many other software companies.
VMware puts the VMM at Ring 0 and the guest
OS at Ring 1. The VMM scans the instruction
stream and identified the privileged, control- and
behavior sensitive instructions.
When these instructions are identified, they are
trapped into the VMM, which emulates the
behavior of these instructions.
The method used in this emulation is called
binary translation. Therefore, full virtualization
combines binary translation and direct execution.
Host-Based Virtualization
• An alternative VM architecture is to install a virtualization
layer on top of the host OS. This host OS is still responsible
for managing the hardware.
• This host-based architecture has some distinct advantages.
First, the user can install this VM architecture without
modifying the host OS. The virtualizing software can rely on
the host OS to provide device drivers and other low-level
services. This will simplify the VM design and ease its
deployment.
• Second, the host-based approach appeals to many host
machine configurations. Compared to the hypervisor/VMM
architecture, the performance of the host-based architecture
may also be low.
Para -virtualization
Para -virtualization needs to modify the guest operating
systems.
A para-virtualized VM provides special APIs requiring
substantial OS modifications in user applications.
Performance degradation is a critical issue of a
virtualized system.
Full Virtualization vs. Para-Virtualization
Full virtualization
Does not need to modify guest OS, and critical instructions are emulated by
software through the use of binary translation.
VMware Workstation applies full virtualization, which uses binary translation to
automatically modify x86 software on-the-fly to replace critical instructions.
Advantage: no need to modify OS.
Disadvantage: binary translation slows down the performance.
Para virtualization
Reduces the overhead, but cost of maintaining a paravirtualized OS is high.
The improvement depends on the workload.
Para virtualization must modify guest OS, non-virtualizable instructions are
replaced by hyper calls that communicate directly with the hypervisor or VMM.
Para virtualization is supported by Xen, Denali and VMware ESX.
Types of Virtualisation
Hardware
Server / OS / Devices ( peripheral devices like printer etc..)
Desktop
Storage ( Memory, hard disk etc..)
Network
Application software
Data
Desktop Virtualization
Virtualization of CPU, Memory, and I/O Devices
A VM is a duplicate of an existing computer system in which a majority of
the VM instructions are executed on the host processor in native mode. Thus,
unprivileged instructions of VMs run directly on the host machine for higher
efficiency. Other critical instructions should be handled carefully for
correctness and stability.
The critical instructions are divided into three categories: privileged
instructions, control –sensitive instructions, and behavior-sensitive
instructions.
Privileged instructions execute in a privileged mode and will be trapped if
executed outside this mode.
Control-sensitive instructions attempt to change the configuration of
resources used.
Behavior-sensitive instructions have different behaviors depending on the
configuration of resources, including the load and store operations over the
virtual memory.
CPU Virtualization
A CPU architecture is virtualizable if it supports the ability to run the
VM’s privileged and unprivileged instructions in the CPU’s user mode
while the VMM runs in supervisor mode.
When the privileged instructions including control- and behavior-
sensitive instructions of a VM are executed, they are trapped in the
VMM. In this case, the VMM acts as a unified mediator for hardware
access from different VMs to guarantee the correctness and stability of
the whole system. However, not all CPU architectures are virtualizable.
RISC CPU architectures can be naturally virtualized because all
control and behavior-sensitive instructions are privileged instructions.
On the contrary, x86 CPU architectures are not primarily designed to
support virtualization.
CPU virtualization
How to virtualize CPU resource?
VM is set one or more vCPUs and each vCPU is allocated to run
applications of Guest OS.
Each application program is denoted by an ordered set of instructions and
finally executed by physical CPU.
During the running of application, app instructions will firstly submitted to
vCPU, then the vCPUs are allocated to physical CPU to run instructions
through VMM scheduling.
Some sensitive instructions only be executed by root user
Non-privileged instruction can be executed in Guest OS
VM0 VMn
APP (Instructions ) APP (Instructions )
vCPU vCPU …... vCPU VMs
VMM
scheduling allocate
pCPU pCPU …… pCPU PM
CPU virtualization approaches
VMWare, Qemu
2)Paravirtualization (PV)
Hardware extension
Intel® Virtualization Technology (Intel® VT)
AMD-V
Hardware support to enable that
Guest OS runs in de-privileged mode to execute
instructions
Guest access to privileged resources triggers exit from
VM to VMM
VM1 VM2
Physical memory
Machine memory
Physical page frame redirection
contiguous
MAP
noncontiguous
Page frame allocation
Partitioning
Simple and high performance
$ to buy more memory
Ballooning
A VMM-aware balloon driver running in guest OS to dynamically
allocate memory from OS and release them to VMM, and vice
versa
Host swapping
The physical frames for guest pages may be swapped out
Shadow page table
Guest memory <-- physical machine memory
Ballooning
Device and I/O Virtualization
Advantage:
• It can run a large amount of legacy binary codes written for
various processors on any given new hardware host machines
• best application flexibility
Shortcoming & limitation:
• One source instruction may require tens or hundreds of native
target instructions to perform its function, which is relatively
slow.
• V-ISA requires adding a processor-specific software
translation layer in the complier.
2.Virtualization at Hardware Abstraction
level:
Hardware-level virtualization is performed right on top of the bare
hardware.
On the one hand, this approach generates a virtual hardware
environment for a VM.
On the other hand, the process manages the underlying hardware
through virtualization.
The idea is to virtualize a computer’s resources, such as its processors,
memory, and I/O devices. The intention is to upgrade the hardware
utilization rate by multiple users concurrently.
Advantage:
Has higher performance and good application isolation
Shortcoming & limitation:
Very expensive to implement (complexity)
Virtualization at HAL
3.Virtualization at Operating System (OS)
level:
OS-level virtualization creates isolated containers on a single physical server
and the OS instances to utilize the hardware and software in data centers.
The containers behave like real servers.
OS-level virtualization is commonly used in creating virtual hosting
environments to allocate hardware resources among a large number of
mutually distrusting users.
Advantage:
Has minimal startup/shutdown cost, low resource requirement, and high
scalability; synchronize VM and host state changes.
Shortcoming & limitation:
All VMs at the operating system level must have the same kind of guest OS
Poor application flexibility and isolation.
Virtualization at OS Level
Advantages of OS Extension for Virtualization
Advantage:
It has very low implementation effort
Shortcoming & limitation:
poor application flexibility and isolation
5.User-Application Level
•Virtualization at the application level virtualizes an application as a VM. On a
traditional OS, an application often runs as a process.
Therefore, application-level virtualization is also known as process-level
virtualization.
• The most popular approach is to deploy high level language (HLL) VMs. In
this scenario, the virtualization layer sits as an application program on top of
the operating system, and the layer exports an abstraction of a VM that can run
programs written and compiled to a particular abstract machine definition.
•Other forms of application-level virtualization are known as
application isolation,
application sandboxing, or application streaming.
Advantage:
•has the best application isolation
Shortcoming & limitation:
•low performance, low application flexibility and high implementation
complexity.
Comparison of Implementation
Levels of Virtualization
The XEN Architecture
Xen is an open source hypervisor program developed by
Cambridge University. Xen is a micro-kernel hypervisor,
which separates the policy from the mechanism.
Xen does not include any device drivers natively . It just
provides a mechanism by which a guest OS can have direct
access to the physical devices.
As a result, the size of the Xen hypervisor is kept rather
small. Xen provides a virtual environment located between
the hardware and the OS.
Benefits of Virtualization
Sharing of resources helps cost reduction
Isolation: Virtual machines are isolated from each other as if they are
physically separated
Encapsulation: Virtual machines encapsulate a complete computing
environment
Hardware Independence: Virtual machines run independently of
underlying hardware
Portability: Virtual machines can be migrated between different hosts.
Advantages of virtual machines
Run operating systems where the physical hardware is unavailable,
Easier to create new machines, backup machines, etc.,
Software testing using “clean” installs of operating systems and software,
Emulate more machines than are physically available,
Timeshare lightly loaded systems on one host,
Debug problems (suspend and resume the problem machine),
Easy migration of virtual machines (shutdown needed or not).
Run legacy systems!