Cloud Computing: Saswati Mukherjee
Cloud Computing: Saswati Mukherjee
Cloud Computing: Saswati Mukherjee
Saswati Mukherjee
What is Virtualization?
Virtualization is a technology that,
when applied on computing
resources, presents an
environment with one or many
operating systems using
methodologies related to
hardware and software using
partial or complete machine
simulation, emulation, time-
sharing, and others.
What is Virtualization?
Definition:
“A Framework or methodology
of dividing the resources of a
computer hardware into
multiple execution
environments, by applying
one or more concepts such as
software partitioning, time
sharing, partial or complete
machine simulation,
emulation”.
Goals of Virtualization
• Allowing any network-enabled device to access any
application over any network, even if that application was
never designed to work with that type of device.
• Isolation of one workload or application from another to
enhance security or manageability of the environment.
• Isolation of an application from the operating system,
allowing an application to continue to function even though
it was designed for a different version of the operating
system.
Goals of Virtualization
• Ability to increase the number of
users working on an application
since multiple instances are run on
different machines simultaneously.
• Ability to decreasing the time it
takes for an application to run, by
segmenting either the data or the
application itself and spreading the
work over many systems.
Goals of Virtualization
• Optimizing the use of a single system, allowing it to work harder and
more intelligently (that is, reducing the amount of time the
processor sits idle without being able to shut down).
Virtualization
Traditional Server Room – Different Machines
Virtualization Layer
Hardware in
host machine
Virtualized Server Room – Machine 2
Application Application
Virtual
OS OS Machines
Application
Hardware Application
Hardware
App
Email
1 1
Server
Server
Windows Linux
Virtualization Layer
Hardware in
host machine
Virtualized Server Room – Machine 3
Application Application Application
Virtual
OS OS OS Machines
Application
Hardware Application
Hardware Application
Hardware
Web1 Email
1 DB Server
1
Server Server Linux
Windows Windows
Virtualization Layer
Hardware in
host machine
Virtualized Server Room – Machine 4
Application Application
Virtual
OS OS Machines
Application
Hardware Application
Hardware
App
Web
1 1
Server
Server
Windows Linux
Virtualization Layer
Hardware in
host machine
How clouds work?
Babu
Charu
Apu
Physical machine
Danish
• Suppose Apu has a machine with 4 CPUs and 8 GB of memory,
and three customers:
• Babu wants a machine with 1 CPU and 3GB of memory
• Charu wants 2 CPUs and 1GB of memory
• Danish wants 1 CPU and 4GB of memory
• What should Apu do?
14
Virtualization is key enabler
Babu
Virtual
machine
monitor
Charu
Apu
Physical machine
Virtual machines Danish
• Apu can sell each customer a virtual machine (VM) with the
requested resources
• From each customer’s perspective, it appears as if they
had a physical machine all by themselves (isolation)
15
Virtualization
“A technique for hiding the physical characteristics of computing
resources from the way in which other systems, applications, or end
users interact with those resources. This includes making a single
physical resource appear to function as multiple logical resources; or it
can include making multiple physical resources appear as a single
logical resource.”
16
The idea of Virtualization: from 1960’s
• IBM VM/370 – A VMM for IBM mainframe
• Multiple OS environments on expensive hardware
• Desirable when few machine around
• Popular research idea in 1960s and 1970s
• Entire conferences on virtual machine monitors
• Hardware/VMM/OS designed together
• Allowed multiple users to share a batch oriented system
• Interest died out in the 1980s and 1990s
• Hardware got more cheaper
• Operating systems got more powerful (e.g. multi-user)
17
A Return to Virtual Machines
• Disco: Stanford research project (SOSP ’97)
• Run commodity OSes on scalable multiprocessors
• Focus on high-end: NUMA, MIPS, IRIX
• Commercial virtual machines for x86 architecture
• VMware Workstation (now EMC) (1999-)
• Connectix VirtualPC (now Microsoft)
• Research virtual machines for x86 architecture
• Xen (SOSP ’03)
• plex86
• OS-level virtualization
• FreeBSD Jails, User-mode-linux, UMLinux
18
Starting Point: A Physical Machine
• Physical Hardware
• Processors, memory, chipset,
I/O devices, etc.
• Resources often grossly
underutilized
• Software
• Tightly coupled to physical
hardware
• Single active OS instance
• OS controls hardware
19
What is a Virtual Machine? •
Software Abstraction
• Behaves like hardware
• Encapsulates all OS and
application state
• Virtualization Layer
• Extra level of indirection
• Decouples hardware, OS
• Enforces isolation
• Multiplexes physical
hardware across VMs
21
Types of Virtualization
• Machine-level virtualization
• Processor virtualization
• Memory virtualization
• Network virtualization
• Storage virtualization
• Desktop virtualization
• Many others…
Machine-Level Virtualization
• WINE/ vCUDA
OS Level Virtualization
• Creating an abstraction layer
between traditional OS and user
applications.
• Also known as containers.
• Isolated containers are created
on a single physical server.
• The containers behave like real
servers.
• Xen/ VMware
ISA Level Virtualization
• Instruction Set Architecture (ISA)
Level
• At the ISA level, virtualization is
performed by emulating a given
ISA by the ISA of the host
machine.
• QEMU/ Dynamo
Types of Virtualization
VMs – Application Containers
Guest Environment
Hardware
Type 1
Three layers: Type 1 hypervisor
Hardware
Type 1
Hypervisor
Hardware
Type 1
• The VMM is installed on the bare
hardware.
• Bare metal hypervisor
• The guest OSs installed above the VMM.
• Run in a less privileged mode.
• Applications also run in lower levels of
privilege.
• The privilege level of the guest OS is
emulated by the VMM.
• Xen and VMware ESX.
Type 1
Type 2
• It is not easy to use and implement
the native or type 1 hypervisor.
• For convenience and simplicity, we
look at the other option of hypervisor
– type 2 or hosted.
• Easier to install a virtual machine
system on an already running OS.
• These systems are called a hosted
• The term host refers to the
underlying OS.
Type 2
• In a hosted VM system, the VMM
utilizes the functions already
available on the host OS to
control and manage resources
desired by each of the virtual
machines.
• These can support the broadest
range of hardware configurations.
• QEMU and VirtualBox.
Type 2
Four layers: Type 2 hypervisor
Applications + Guest OS+ Virtual H/w Applications + Guest OS+ Virtual H/w
Host OS
Hardware
Type 2
Hypervisor
Host OS
Hardware
Type 2
Hybrid
• The efficiency of virtualization
is not visible in Type 1, since
the hypervisor works like an
application.
• Some part of the VMM must
work in higher privilege mode.
• Desirable.
• This can be achieved by
creating a hybrid model.
Hybrid
• The VMM shares the hardware with
a host operating system.
• This is done through mechanisms
commonly provided to extend the
functionality of an operating system
• kernel extensions
• device drivers.
• It has parts of the VMM working in a
privileged mode and other parts in
nonprivileged mode.
Hybrid
• Also known as a dual-mode hosted
VM system.
• Supports multiple virtual machines.
Guest Guest
OS A OS B Appli- Appli-
cations cations
VM1 VM2
Hypervisor Host OS
Hardware
System Call Example
App App
OS OS
VMM VMM
Hardware Hardware
Storage
VM Suspension
App
OS
VMM VMM
Hardware Hardware
App
Storage
OS
VM Provisioning
App App
OS OS
VMM VMM
Hardware Hardware
Storage
VM Migration
App App
OS OS
VMM VMM
Hardware Hardware
Storage
VM Benefits
• Familiar Interfaces
• VM provides the same
interface as the OS.
• Flexibility of Applications
• Different operating systems
may run on different VMs.
• Security
• Isolation of applications in
VMs provides security.
• Server Consolidation
VM Benefits
• High Availability
• Save the VM and run it
again
• Live migration
• Not affected by failures
• Simplified Environment
• Scalability
• Backup with Fast Recovery
• Portability
What is coming….
• What is virtualization?
• What are the types of
virtualization?
• What are the types of VM?
Upcoming
• What is virtualizability?
• Popek-Goldberg theorem.
• What is x86 architecture.
• Problems of x86 architecture.
CPU Virtualization
CPU virtualization is an environment
that offers one or more of the
followings:
• Emulates a physical environment in
software.
• Provides a hardware-like view to
processes while the processes are not
running on top of the hardware.
• Creates the capability of running an
operating system inside another OS.
• Runs more than one OS on a single
physical hardware.
Virtualization and Emulation
• Emulation is a common
phenomena.
• What is emulation?
• How to implement emulation?
• Interpretation
• Needed?
• Binary translation
• Good enough?
• Virtualization is similar but not
the same:
• What does it mean?
Virtualization Requirements
• Virtualization requires the guests
to have near-native behaviour.
• Since virtualization is on the
same ISA, what is required for
two different OSs to run on one
hardware?
• Managing the execution
• Easy – allow any one.
• But there is more to it!
• Let us understand this.
Third Generation Computers
Essentially today’s computers follow this
generation of computers:
• Integrated circuit based – 1964-1971
• Interfaced with an operating system.
• Concurrent applications
• Imposes certain restrictions on processes.
• Dual mode of CPU execution:
• Privileged mode and
• User mode.
• OS is empowered with the
supervisor/privileged mode.
Third Generation Computers
• When a user process
executes:
• Only generic set of
instructions are executable.
• Mode of CPU ensures this.
• When a OS process
executes:
• All the instruction are
executed.
• Does it always work?
Third Generation Computers
• What happens when a user process
wants to execute a special
instruction?
• Only OS can execute.
• Such instructions cause the CPU to
change the mode and bring in a OS
process that is capable of executing
this instruction on the behalf of the
user process.
• Called the ‘trapping to OS’.
Trapping to OS
• A user mode instruction traps
whenever it tries to execute a
special instruction:
• For any I/O operation.
• For other special action.
• The mode changes to privileged.
• The execution of the instruction is
carried out by the OS (if
permissible).
• The results are passed on to the
respective (calling) user process.
Virtualization Requirements
How do things work? Application
• Traditional OS – Layered
Trap to OS
approach.
• Normal application instructions
Traditional OS
run on the hardware:
• CPU in user mode. Special Routine
Nonprivileged Privileged
Sensitive
Popek-Goldberg Theorem
• The requirement is that we need to add one virtualization layer
above the hardware.
• Theorem:
Nonprivileged Nonprivileged
Privileged
Privileged
Sensitive Sensitive
OS Kernel
mode
Deprivileging the OS
Depriviledged scenario
Virtual
App App User
mode
User
Virtual
mode
OS Kernel
mode
VMM
Kernel
mode
Methods of Virtualization
• By definition, the privileged
state of a virtual system differs
from that of the underlying
hardware.
• The VMM’s basic function is to
provide an execution
environment that meets the
guest’s expectations in spite of
this difference.
Methods of Virtualization
• Emulation
• Trap and Emulate
• Binary Translation
Emulation
• Both the application and the
guest OS run in the user mode.
• Catch hold of each instructions
of the user mode and translate
it to an equivalent instruction:
• Interpretation
• Very expensive to interpret
each instruction.
• Needed?
Trap-and-Emulate
• Guest, i.e., both application and the guest
OS run in the user mode.
• Virtual user and virtual kernel mode.
• VMM runs in privileged mode.
• When a privileged instruction is to be
executed in virtual user mode, a trap to the
virtual kernel mode occurs.
• This, in turn, causes VMM to gain control
of the execution.
Trap-and-Emulate
• When VMM traps:
• It executes the necessary equivalent
operations in the underlying ISA.
• Returns control to guest in user mode.
• User mode code in guest runs at
normal speed.
• No change from running in non-
virtualized environment.
• But kernel mode privileged codes run
slower due to trap-and-emulate.
Trap-and-Emulate
• The mechanism works fine.
• Except kernel mode
running slower.
• Small issue is when there
are several guests:
• Each needs trap-and-
emulate for all privileged
mode instructions.
Trap-and-Emulate
User Process
VMM
VMM
Kernel Mode
Courtesy: Silberschatz[3]
Trap-and-Emulate
Courtesy: Silberschatz[3]
Trap-and-Emulate – Problems
• Not all ISAs can be emulated using trap-and-
emulate method.
• Those that do not follow Popek Goldberg theorem.
• Sensitive instructions are not Privileged
instructions.
• Intel x86 is an example.
• Consider Intel x86 popf instruction
• Loads CPU flags register from contents of stack
• In privileged mode → all flags are replaced
• In user mode → only some flags are replaced
• No trap is generated.
Binary Translation
• Binary Translation solves problems of
trap-and-emulate.
• Concept is simple, but
implementations are complex.
• If guest vCPU is in user mode, guest
can run instructions natively.
• If guest vCPU in kernel mode
• VMM checks every instruction
• Non-sensitive instructions run normally
• Sensitive instructions are translated
appropriate to the underlying ISA.
Binary Translation
• Performance of this method is worse
than trap-and-emulate.
• Optimizations are possible.
• Use caching to improve performance.
• Cache what?
• Translate once, and when guest executes
code containing sensitive instruction –
• Check cached translation.
• Translate if not available.
• This solves the efficiency problem of
Binary Translation.
Binary Translation
Courtesy: Silberschatz[3]
CPU Virtualization in Practice
Four methods
• Emulation
• Interpretation.
• Full virtualization with
dynamic binary translation.
• Paravirtualization.
• Hardware-assisted
virtualization.
Emulation
• Interpret the guest code.
• Efficiently emulates only those
hardware components so that user
does not understand the difference.
• Only CPU & memory are sufficient to
emulate.
• Performance can be improved by
some additional methods
• Typically reduces system accuracy.
Full Virtualization
What do we want?
• Run an existing OS and applications in
an isolated VM.
• We should be able to run many such
VMs without affecting each other (not in
ring 0, of course!)
• A host OS should supervise.
• What would make this unsafe?
• All instructions executed on the
processor that modify the state of
the machine.
Full Virtualization
How do we ensure safety?
• Intercept or rewrite all
those instructions that can cause
problem.
• What about the performance?
• All the other instructions (safe
ones) can run directly on the
physical hardware.
• Full Virtualization.
Full Virtualization
• In full virtualization one or more guest operating
systems share hardware resources from the host
system.
• The presence of the hypervisor is not known to the
guests.
• Full virtualization requires a virtualizable architecture:
• The hardware is fully exposed to the guest OS.
• Guest OS runs unchanged.
• Ensures greater efficiency.
• X86 is not virtualizable!!
Problem of x86
• In the ring architecture of x86:
• Where to run the guest os?
• Where to run the VMM?
• In full virtualization
• Run guest OS in Ring 1/3
• Deprivilege guest OS
• Run VMM in Ring 0.
• Running unmodified guest OS
in a higher ring has certain
problems.
Problem of x86
• x86 ISA does not meet the Popek & Goldberg requirements for
virtualization
• ISA contains 17+ sensitive, unprivileged instructions:
• SGDT, SIDT, SLDT, SMSW, PUSHF, POPF, LAR, LSL, VERR, VERW, POP, PUSH,
CALL, JMP, INT, RET, STR, MOV
• Most simply reveal the processor's CPL
• Virtualization is still possible, requires a workaround
The “POPF Problem”
Ring 2 Direct
Execution
Ring 1 Guest OS of User VMware (1998)
Requests
Ring 2
Direct
Ring 1 Execution
of User
Paravirtualized
Ring 0 Guest OS Requests
Virtualization Hypercalls to
Layer virtualization
layer
Host Computer
Hardware
Paravirtualization Challenges
• Guest OS must be modified for
this purpose.
• Causes problems in OS
maintainability and
supportability.
• Guest OS and hypervisor are
tightly coupled.
• Hence compatibility problem.
• Guest kernel must be recompiled
when hypervisor is updated.
Hardware-Assisted Virtualization
• Why are there so many problems and
difficulties ?
• Some critical instructions do not trap in user
mode.
• Legacy processors were not designed for
virtualization.
• With virtualization-aware processors, the VMM
design will be more efficient and simple.
• Solution:
• Some instructions must be redefined.
• CPU control paradigm must be changed.
Hardware-Assisted Virtualization
• Rather than making software
adjustments, change the hardware.
• Modern x86's meet Popek &
Goldberg requirements
• Intel VT-x (2005), AMD-V (2006)
• VT-x introduces two operating
modes:
• “VMX root” operation
• Runs VMM
• “VMX non-root” operation
• Runs guest OS
Hardware-Assisted Virtualization
• Both modes support all
privilege rings.
• Guest OS (unmodified) runs in
ring 0 in non-root mode.
• Traps to root mode.
• Privileged and sensitive calls
automatically trap to the
hypervisor.
• VMM controls the execution of
the guest OS.
Hardware-Assisted Virtualization(check)
Dom U Dom U
Dom 0 PV HVM
guest guest
Xen hypervisor
Processor
disk NIC VGA Hardware
Memory
Xen Components
•Hypervisor
• Handles all the low
level functionality
• Responsible for CPU
scheduling and
memory partitioning.
• Domain 0
• Domain U
Xen Components
• Domain 0
• Modified Linux kernel
• A VM with special rights
• Accesses physical I/O resource
• interacts with other virtual machines
• Domain U
• Physical hardware is inaccessible here
• Paravirtualized VMs – DomU PV Guests (Linux, Solaris,
FreeBSD, UNIX)
• Full virtualized VMs -- DomU HVM guests (Windows)
Xen and Future
Xen is a popular hypervisor and
enjoys support from various
vendors:
• Sun Microsystems
• Hewlett-Packard
• Novell
• Red Hat
• Intel
• Advanced Micro Devices
• Voltaire
• IBM
Summary
• What are the various
methods of virtualization.
• Implementations of CPU
virtualization.
• Xen hypervisor.
Next Class
• Web services.
References
1. Popek, Gerald J., and Robert P. Goldberg. "Formal requirements for
virtualizable third generation architectures." Communications of the
ACM17.7 (1974): 412-421.
2. Smith, J. E., and Ravi Nair. "Virtual Machines: Architectures,
Implementations and Applications." Morgan Kauffmann (2004).
3. Hwang, Kai, Jack Dongarra, and Geoffrey C. Fox, “Distributed and
Cloud Computing: From Parallel Processing to the Internet of
Things”, Morgan Kaufmann, 2013.
THANK YOU!
References
1. Smith, J. E., and Ravi Nair. "Virtual Machines: Architectures,
Implementations and Applications." Morgan Kauffmann, 2004.
2. Popek, Gerald J., and Robert P. Goldberg. "Formal requirements for
virtualizable third generation architectures." Communications of the
ACM17.7 (1974): 412-421.
3. Figueiredo, Renato, and Peter A. Dinda. "Guest Editors' Introduction:
Resource Virtualization Renaissance." Computer 5, 28-31, 2005.
4. Hwang, Kai, Jack Dongarra, and Geoffrey C. Fox, “Distributed and Cloud
Computing: From Parallel Processing to the Internet of Things”, Morgan
Kaufmann, 2013.
5. Marinescu, Dan C. ”Cloud Computing: Theory and Practice.” Newnes,
2013.