module3virtualization
module3virtualization
Hypervisor
Hardware
Application
Application
OS
OS
Virtualization Layer
Virtualization Layer
OS
Hardware
Hardware
Hardware
11
Type 2
UNF University of
NORTH FLORIDA Hypervisor implementation approaches
Hosted Approach
VM VM • Type II Hypervisor.
• Runs virtual machines on top of a
Applications host OS (windows, Unix etc.)
Hypervisor
• Relies on host OS for physical
resource management.
• Host operating system provides
drivers for communicating with the
server hardware.
Host Operating System • E.g.: VirtualBox
Hardware
13
System Virtualization
Interfaces with operating system
OS sees VM as an actual machine—memory, I/O,
CPU, etc
Classic virtualization: virtualization layer runs
atop the hardware.
Usually found on servers (Xen, VMWare ESX)
Hosted or whole-system virtualization:
virtualization runs on an operating system
Popular for desktops (VMWare Workstation, Virtual
PC)
Roles of the Hypervisor
Isolating/Emulating resources
CPU: Scheduling virtual machines Push to HW /
Memory: Managing memory Pre-allocation
Example: QEMU
Breaks CPU instructions into small ops, coded in
C.
C code is compiled into small objects on native
ISA.
dyngen utility runs code by dynamically
stitching objects together (dynamic code
generation).
UNF University of
NORTH FLORIDA
Full virtualization
• Enables hypervisors to
run an unmodified guest
operating system (e.g.
Multiple Software Multiple Software
Applications Applications Windows 2003 or XP).
Operating System Operating System • Guest OS is not aware
Virtual Server 1 Virtual Server 2 that it is being virtualized.
Hypervisor
• E.g.: VMware uses a
combination of direct
Hardware execution and binary
translation techniques to
achieve full virtualization
CPU Memory NIC DISK of server systems.
19
UNF University of
NORTH FLORIDA
Binary Translation with Full Virtualization
“Hardware is functionally
identical to underlying
architecture.”
Typically accomplished
through interpretation or
binary translation.
Advantage: Guest OS will run
without any changes to
source code.
Disadvantage:Complex,
usually slower than
paravirtualization.
UNF University of
NORTH FLORIDA
Para virtualization
• Involves explicitly
modifying guest operating
Multiple Software Multiple Software system (e.g. SUSE Linux
Applications Applications
Enterprise Server 11) so
Para virtualized Para virtualized
Guest
Operating System
Guest
Operating System
that it is aware of being
Virtual Server 1 Virtual Server 2
virtualized to allow near
native performance.
Hypervisor / VMM • Improves performance.
Hardware • Lower overhead.
• E.g.: Xen supports both
Hardware Assisted
CPU Memory NIC DISK
Virtualization (HVM) and
Para-Virtualization (PV).
22
UNF University of
NORTH FLORIDA
Paravirtualization
Replace certain
unvirtualized sections of OS
code with
virtualization-friendly code.
Advantages:
easier, lower virtualization
overhead
Disadvantages:
requires modifications to
guest OS
UNF University of
NORTH FLORIDA
UNF University of
NORTH FLORIDA
Performance
Modern VMMs based around
trap-and-emulate .
When a guest OS executes a
privileged instruction,
control is passed to VMM
(VMM “traps” on Guest OS
instruction), which decides CPU_INST
how to handle instruction .
VMM generates instructions TRAP VMM
to handle trapped
instruction (emulation). CPU_INST1
Trap-and-emulate is expensive
Requires context-switch from guest OS mode to VMM.
x86 is not trap-friendly
fram
e
VM to MM USING PT(PM)
TLB& MMU for high performance
*Intel and AMD add an additional mode called privilege mode level
(some people call it Ring-1) to x86 processors
Gues
t
Drive
r
Virtua
l
Devic
eVMM
Virtua
l
Driver
Physical Device
Switching Expense
Low-level I/O functionality happens at the VMM level,
requiring a context switch.
Xen
Virtualization
Xen occupies privilege level 0; guest OS occupies privilege
level 1.
OS code is modified so that high-privilege calls (hypercalls)
are made to and trapped by Xen .
Xen traps guest OS instructions using table of exception
handlers.