Virtualization II-2019-SysVM
Virtualization II-2019-SysVM
Virtualization II-2019-SysVM
(part II)
05/17/2019
Efficient Emulation for VM
Process Virtual Machines: Often Cross-ISA
Stack
Interpreter
Code
Example
Stack
Interpreter
Code
Decode-Dispatch Interpretation
LoadWord(inst)
{
RT = extract (inst,25,5);
RA = extract (inst,20,5);
displacement =extract (inst,15,16);
source = regs[RA];
address = source + displacement ;
regs[RT] = data[address];
PC = PC + 4;
}
From executable to executable
Source ISA: assume MIPS
addl %eax,%ebx,%ecx
Add r1, r2, r3 …..
Ld r4, 4(sp) movl %edx,4(%esp)
Add r5, r4, r6 …..
… movl %ecx, 100(%esp);
… Code movl %edx, 104(%esp);
Morphing addl %eax, %ecx,%edx;
movl %eax, 108(%esp);
….
….
Department of Computer
Science and Engineering 15
Retargetable
DynamicBinaryTranslation
Guests Hosts
ARMv7 ARMv7
QEMU
ARMv8 ARMv8
X86
DBT IR X86
MIPS MIPS
New ISAs
Department of Computer
Science and Engineering
Application Virtualization
Isolation Properties
– Fault isolation, Software isolation
– Performance isolation
Encapsulation
– Cleanly capture all VM states
– Enables VM snapshots, clones
Migration
– Independent of physical hardware
– Enables migration of live VMs
Interposition
– All requests go through VMM – this allows VM management such as
profiling, encryption, compression, replication.
System VMs 17
Application Virtualization
Resource consolidation
– Server consolidation
– Client consolidation
Simultaneous support for multiple OSes/Apps
– Easy way to implement timesharing, e.g. IBM System/370
Simultaneous support for different OSes/Apps
– E.g. Windows and Unix
Error containment
– If one VM crashes, the other VMs can continue to work
Assumes VMM is correct (smaller/simpler)
Operating System debugging
– Can proceed while system is being used for normal work
System VMs 18
Resource Consolidation
Server consolidation
– Reduce number of servers
– Reduce space, power and cooling
– 70-80% reduction numbers cited in industry
Client consolidation
– Developers: test multiple OS versions, distributed application
configurations on a single machine
– End user: Windows on Linux, Windows on Mac
– Reduce physical desktop space, avoid managing multiple
physical computers
System VMs 19
Application Virtualization, contd.
Operating System Migration
– Can proceed while “old” OS continues to be
used TIME
New System Programmers System Programmers
Release Converted
Production Users
Converted
Old Production Users
Unconverted Production Users
Release Production Users
Permanently
Unconverted
Production Users
new release new release newer release
being tested installed being tested
System VMs 20
Today’s Applications
Server Consolidation
App
App
… App
App App OS OS
… OS
OS OS
VMM
HW VMM HW HW
HW
HW
R&D Production
App
OS
VMM
HW
Benefit: Business Agility and Productivity
Emerging Applications
Continuity % %
Disaster Recovery
Partitioning Dynamic load
balancing
App App App App
1 2 3 4
OS OS OS OS
VMM
HW
CPU Virtualization
ISA Virtualizablity
Ideally, if an ISA has
privileged instructions
Non-privileged
and non-privileged instructions
exclusively separated so that
Privileged all control-sensitive and
behavior-sensitive instructions
are privileged instructions, then
The trap-and-emulate model can
be efficiently implemented.
System VMs 23
Instruction Types -- Summary
Non-
Privileged
Innocuous
Privileged
System VMs 24
Non-
Privileged
Innocuous
Privileged
System VMs 25
Para-Virtualization vs. Full Virtualization
Full Virtualization (FV)
– Transparent. Guest OSes are unmodified.
Para-Virtualization (PV)
– //Actively modify guest OS’ necessary parts
– Special hooks to allow the guests and host to
communicate.
– Simplifies VMM and reduce overhead
– Require the guest OS to be explicitly ported for the
“Para-API”.
System VMs 26
Hardware Assisted System VM: Intel’s VT-x
Pre VT-x Post VT-x
Source: [2] 27
Full Virtualization
Support multiple guest OSes on a single hardware
platform; all running the same ISA
Windows Solaris
Linux Application
Application Application
traps
Hypervisor
Intel x86
Hardware
Memory I/O devices
System VMs 28
SW-Assisted Virtualization
DBT to translate
Windows Solaris
Linux Application
Application Application
traps
Hypervisor
Intel x86
Hardware
Memory + Support for VM I/O devices
System VMs 29
HW-Assisted Virtualization
Hardware support virtualization have been added to
simplify Full Virtualization since 2005, such as Intel
VT-x, VT-i, VT-d, VT-c, AMD-V, ….
Windows Solaris
Linux Application
Application Application
traps
Hypervisor
Intel x86
Hardware
Memory + Support for VM I/O devices
System VMs 30
Para-virtualization
Guest OSes may be modified to communicate with the
hypervisor via hypercalls. I/O drivers have been
specialized.
Windows Solaris
Linux Application
Application Application
Hypercalls
Hypervisor
Intel x86
Hardware
Memory I/O devices
System VMs 31
Identical Guest Systems
Support multiple guest OSes on a single hardware
platform; all running the same ISA
Linux Linux Linux
Application Application Application
Intel x86
Hardware
Memory I/O devices
System VMs 32
Multi-processing in Linux
Linux OS
Intel x86
Hardware
Memory I/O devices
System VMs 33
Container/Docker
System Application Application
Containers Containers Containers
(e.g. openVZ) (e.g. Docker) (e.g. Docker)
Container Engine
Linux OS
Intel x86
Hardware
Memory I/O devices
System VMs 34
Container Technology
Container is a virtual environment which groups and isolates a set
of processes and resources from the host and other containers.
There is a tremendous surge of interest in the use of various
container technologies in cloud computing in recent years.
Docker is intended to run a single application, such as MySQL,
Nginx (a web server or a load balancer), or Redis (key-value
database). If you want to run two or more applications, should
consider two dockers or using a system container (such LXC – a
Linux instance).
Container has often been called “Lightweight virtual machine”.
Compared to VM, containers have a more limited scope. However,
containers have lower overhead, hence are welcome by cloud
computing community.
System VMs 35
Native VM (Type-I) vs. Hosted VMs (Type-II)
Virtual Virtual
Applications Machine Machine
Non-privileged
Applications
modes
VMM VMM
OS
Type-I Type-II
System VMs 36
Native System VM Environment
Linux Windows Solaris
Applications Applications Applications
Guest OS Guest OS
(Windows) (Windows)
Example: Can patch
VMware VMM privileged
GSX server instructions to
VMM calls
Hosted OS (Linux) (traps), or using
DBT techniques
Parallels (Windows/Mac/Linux)
Vmware (Windows/Linux)
QEMU (Linux)
System VMs 39
VirtualBox
• Available for x86
based machines
(both Intel and
AMD).
• Users can load
multiple guest OS
under a single
host OS.
• Support both
software-based
and hardware-
based
virtualization.
• Open Source
Software
• Free
System VMs 40
Parallel
• Available for Apple
Mac/intel based
machines
• Users can load
multiple guest OS
(e.g. Linux,
Windows) under a
single Mac host
OS.
• $79.99 (~NTD
$2600)
System VMs 41
VMware
• Available for x86
based machines
(both Intel and
AMD, and Mac).
• Users can load
multiple guest OS
under a single
host OS.
• VMware fusion
lets you run >200
OS, including
Window XP thru
Windows 8.
• Deliver Windows
applications to
Mac users
• $189
System VMs 42
QEMU
• A generic and open
source machine
emulator and virtualizer,
supporting both process
VM and system VM.
• When used as a
machine emulator,
QEMU can run OS and
applications cross ISA
(e.g. ARM app on PC)
with good performance.
• QEMU supports
virtualization when
executing under Xen or
KVM hypervisors.
• Free
System VMs 43
Intel VT-x Technology (Vanderpool)
New CPU Modes: VMX root/non-root
modes
– VMM runs in VMX root mode
– Guest VM runs in VMX non-root mode
– Each mode has ring 0 to ring 3
Virtual Machine Control Structure (VMCS)
Transitions
– VM entry: root to non-root transition
– VM exit: non-root to root transition
System VMs 44
VMCS
VMCS consists of 6 control groups
Guest state area
– Guest states saved on VM exits and loaded
on VM entries
Host state area
– Host states loaded from the host state area on
VM exits
VM execution control fields
VM-exit control fields
VM-entry control fields
VM-exit information fields
System VMs 45
VM Timesharing
VMM Timeshares resources among guests
– Similar to OS timesharing applications
VMM Active
First VM Active Next VM Active
System VMs 46
VM Timesharing
VMM Timeshares resources among guests
– Similar to OS timesharing applications
System VMs 47