05 - Virtualization
05 - Virtualization
Cloud Computing
Chapter 05
Virtualization
VM3 VM3
5
Case Study: Amazon AWS EC2
• Virtualization plays an important role in AWS for
making cloud virtual machine EC2.
• A brief introduction video from AWS Academy.
6
Hypervisor or VMM
• In a virtualized computer, many operating systems
(called guest OSs) can run on the same hardware,
independent of the host OS.
— The virtual machines should be isolated.
— The host OS manages hardware resources and the guest
OSs. Sometimes the hypervisor takes the duty of host OS.
7
Hypervisor
8
Hypervisor
• Inserted between hardware and operating
systems.
—Responsible for allocating hardware resources for
programs;
—To disallow a program to access any resource not
explicitly allocated to it;
—To regain control of resources which is already
allocated under certain circumstances;
9
Examples of Hypervisors
• XEN
• VirtualBox
• Hyper-V
• VMware ESX
• KVM
• Docker
10
11
VM Architectures
12
Five Levels of Virtualization
Implementation
• Virtualization can be
implemented at different
levels
— Instruction set architecture
(ISA) level: to emulate a
given ISA by the ISA of the
host machine.
— Hardware level: it generates
a virtual hardware
environment for a VM.
— Operating system level
— Library support level
— Application (or process)
level: application isolation
or sandboxing
13
INSTRUCTION SET
ARCHITECTURE LEVEL
14
Instruction Set Architecture
Level
• Support the emulation of different CPU
• E.g. Running Android Apps (in ARM
architecture) over a Windows machine (in x64
architecture) with the help of ISA emulation.
App
17
Hardware Abstraction
• Generates a virtual hardware environment for a
VM
—CPU Virtualization
—Memory Virtualization
—GPU Virtualization
—I/O Virtualization
21
Comparing Full/Para
Virtualization
Full Virtualization Para Virtualization
22
Hardware-assisted
Virtualization
• Hardware-assisted Virtualization improve over
Full and Para virtualization
23
CPU Virtualization
24
Memory Virtualization
• Hardware-assisted memory virtualization: in
virtualized environment, there is a two-stage
memory mapping: from virtual memory to
physical memory to machine memory.
—Intel uses “Extended Page Table” technique to
improve the performance of memory address
translation.
—AMD uses “Nested Page Tables” or “Rapid
Virtualization Indexing” to address the issue.
25
Memory Virtualization
26
VT-x in BIOS
27
OPERATING SYSTEM
LEVEL
28
OS-level Virtualization
• OS-level virtualization inserts a virtualization layer
inside an operating system to partition a machine’s
physical resources.
• Create isolated containers on the OS instances to
utilize the hardware and software in data centers.
• Multiple isolated VMs are isolated in the single
operating system kernel.
— The VMs are also known as Virtual Execution Environment
(VE), Virtual Private System (VPS), or Container.
29
Architecture: Container vs VM
30
img: Microsoft.com
Virtual machine Container
Isolation Provides complete isolation from the host operating system Typically provides lightweight isolation from the host and other
and other VMs. This is useful when a strong security containers, but doesn't provide as strong a security boundary as a VM.
boundary is critical, such as hosting apps from competing
companies on the same server or cluster.
Operating system Runs a complete operating system including the kernel, thus Runs the user mode portion of an operating system, and can be tailored
requiring more system resources (CPU, memory, and to contain just the needed services for your app, using fewer system
storage). resources.
Guest compatibility Runs just about any operating system inside the virtual Runs on the same operating system version as the host (Hyper-V
machine isolation enables you to run earlier versions of the same OS in a
lightweight VM environment)
Deployment Deploy individual VMs by using Windows Admin Center or Deploy individual containers by using Docker via command line; deploy
Hyper-V Manager; deploy multiple VMs by using PowerShell multiple containers by using an orchestrator such as Azure Kubernetes
or System Center Virtual Machine Manager. Service.
Operating system Download and install operating system updates on each VM. 1.Updating or upgrading the operating system files within a container is
updates and upgrades Installing a new operating system version requires upgrading the same:
or often just creating an entirely new VM. This can be time- Edit your container image's build file (known as a Dockerfile) to point to
consuming, especially if you have a lot of VMs... the latest version of the Windows base image.
2.Rebuild your container image with this new base image.
3.Push the container image to your container registry.
4.Redeploy using an orchestrator.
The orchestrator provides powerful automation for doing this at scale.
Persistent storage Use a virtual hard disk (VHD) for local storage for a single Use Azure Disks for local storage for a single node, or Azure Files (SMB
VM, or an SMB file share for storage shared by multiple shares) for storage shared by multiple nodes or servers.
servers
Load balancing Virtual machine load balancing moves running VMs to other Containers themselves don't move; instead an orchestrator can
servers in a failover cluster. automatically start or stop containers on cluster nodes to manage
changes in load and availability.
Fault tolerance VMs can fail over to another server in a cluster, with the VM's If a cluster node fails, any containers running on it are rapidly recreated
operating system restarting on the new server. by the orchestrator on another cluster node.
Networking Uses virtual network adapters. Uses an isolated view of a virtual network adapter, providing a little less
virtualization–the host's firewall is shared with containers–while using
less resources.
31
Ref:Microsoft.com
OS-level Virtualization (Cont.)
• Advantages:
—Minimal startup/shutdown costs, low resource
requirement, high scalability
—It’s possible to synchronize state changes between
the VM and the host environment
—Container is designed to encapsulate “an application
and its running environment”, not an “OS”.
• Disadvantage:
—All VMs on a single container must use the same
operating system.
32
LIBRARY SUPPORT LEVEL
33
Library Support Level
• Most applications use APIs (libraries) rather
than lengthy system calls by the OS.
• Examples:
—WINE: running Windows applications on UNIX hosts
—vCUDA: allows applications within VMs to leverage
GPU hardware acceleration
35
USER APPLICATION LEVEL
36
User Application Level
• Also known as process-level virtualization.
• Deploy high level language (HLL) VMs.
• Example:
—Microsoft .NET
—Java virtual machine (JVM)
37
Virtual Clusters
• A virtual cluster consists of a set of VMs that can
communicate through a (virtual) network.
38
VM Migration
39
VM Live Migration
• Sometimes a VM needs to be reallocated to a different physical
node. “Live” means the user service will not be affected (or with very
minor impact) during the VM migration.
— E.g., the current physical node is heavily loaded. Some VMs are selected to
be migrated to other lightly loaded physical nodes.
— E.g., the current physical node is too lightly loaded. All VMs are migrated to
other physical nodes, so that this physical node can be turned off or put into
deep sleep state to reduce energy consumption.
https://docs.microsoft.com/en-
us/virtualization/hyper-v-on-
windows/quick-start/quick-create-
virtual-machine
41
Hyper-V
• Hyper-V does not need to be
installed.
• It can be enabled through
Settings.
• Enable “Virtualization” in
BIOS.
• Expect a multi-core machine
with at least 8GB
42
Hyper-V Manager
• Hyper-V Manager is an application that manage
different Hyper-V instances.
• It allocates resources for each instance and to
control their life-cycle
(create/start/stop/pause/delete)
—CPU
—RAM
—HD
—Network
44