virtual machines - androbenchcsl.skku.edu/uploads/sse3044f15/18-virtualization.pdf ·...
TRANSCRIPT
Virtual Machines
Jinkyu Jeong ([email protected])
Computer Systems Laboratory
Sungkyunkwan University
http://csl.skku.edu
2 SSE3044: Operating Systems | Fall 2015 | Jinkyu Jeong ([email protected])
Today's Topics
History and benefits of virtual machines
Virtual machine technologies
Virtualization implementation methods
Hardware-supported virtualization
Cloud computing
3 SSE3044: Operating Systems | Fall 2015 | Jinkyu Jeong ([email protected])
Overview
Fundamental idea • Abstract hardware of a single computer into several different
execution environments
• Similar to layered approach
• But layer creates virtual system (virtual machine, or VM) on which operation systems or applications can run
Several components • Host – underlying hardware system
• Virtual machine manager (VMM) or hypervisor – creates and runs virtual machines by providing interface that is identical to the host
• Guest – process provided with virtual copy of the host
Single physical machine can run multiple operating systems concurrently, each in its own virtual machine
4 SSE3044: Operating Systems | Fall 2015 | Jinkyu Jeong ([email protected])
System Models
Non-virtual machine Virtual machine
5 SSE3044: Operating Systems | Fall 2015 | Jinkyu Jeong ([email protected])
Why Virtualization?
Efficient resource utilization • Low resource utilization of each server machine
• Consolidate multiple servers on a single physical machine
Flexible VM management • VM suspend, resume, snapshot, clone
• Live migration – no interruption of service
Strong isolation • Host system protected from VMs, VMs protected from
each other
Multiple OSes on a single machine • Windows + Linux
• OS development at user-level
6 SSE3044: Operating Systems | Fall 2015 | Jinkyu Jeong ([email protected])
Types of VMM
Type 0 hypervisors • Hardware-based solutions
– IBM LPARs and Oracle LDOMs are examples
Type 1 hypervisors • Operating-system-like software
built to provide virtualization
– VMware ESX, Citrix XenServer
Type 2 hypervisors • Applications on operating
systems provide VMM features
– VMware Workstation, Parallels Desktop, and Oracle VirtualBox
7 SSE3044: Operating Systems | Fall 2015 | Jinkyu Jeong ([email protected])
VMM Implementation
Goal
• Provide an illusion of multiple machines
• Retain control of the physical machine
CPU virtualization
Memory virtualization
I/O virtualization
8 SSE3044: Operating Systems | Fall 2015 | Jinkyu Jeong ([email protected])
CPU Virtualization
VMM runs in kernel-mode
Guest OS runs in user-mode
Trap-and-emulate • Attempting a privileged
instruction in user mode causes an error -> trap
• VMM gains control, analyzes error, executes operation as attempted by guest
• Returns control to guest in user mode
9 SSE3044: Operating Systems | Fall 2015 | Jinkyu Jeong ([email protected])
x86 CPU Virtualization
x86 architecture is not fully virtualizable
• Certain privileged instructions behave differently when run in unprivileged mode
• Certain unprivileged instructions can access privileged state
Techniques to address inability to virtualize x86
• Replace non-virtualizable instructions with easily virtualized ones statically (Para-virtualization)
• Perform Binary Translation (Full Virtualization)
10 SSE3044: Operating Systems | Fall 2015 | Jinkyu Jeong ([email protected])
Memory Virtualization (1)
OS assumes it has full control over memory
• Managing physical memory and mapping virtual page to physical page
VMM wants to partition physical memory among VMs
• VMM needs to manage physical memory
• VMM wants to control OS virtual page mappings – OS can only map a physical page given by VMM
Hardware-managed TLBs make this difficult
• Once TLB miss, hardware walks page tables
• VMM needs to control access by OS to page tables
11 SSE3044: Operating Systems | Fall 2015 | Jinkyu Jeong ([email protected])
Memory Virtualization (2)
Shadow paging • VMM manages a shadow of a VM’s page table
• VM’s page table is marked read-only
• When guest OS updates its page table – Trap-and-emulate: VMM updates the shadow
• Page table base register sees shadow page table
Para-virtualized paging • Guest OS manages page table
• Guest OS is modified to make a call to VMM when updating its page table
– Hypercall
• VMM validates and update VM’s page table
• Page table base register sees VM’s page table
12 SSE3044: Operating Systems | Fall 2015 | Jinkyu Jeong ([email protected])
I/O Virtualization
VMM provides virtual I/O devices for sharing between VMMs • Full-virtualized device model
– Trap-and-emulate
• Para-virtualized device model – Virtualization-aware device drivers
» Front-end driver in guest OS
» Back-end driver in VMM
– Shared memory communication specialized to virtualization
• Performance penalty due to virtualization overhead
• Devices can be shared between VMs
Guest OS manages device directly • No performance penalty
• Impossible to share a device between VMs
13 SSE3044: Operating Systems | Fall 2015 | Jinkyu Jeong ([email protected])
Hardware-supported Virtualization
CPU architecture supports virtualization • CPU virtualization
– Additional CPU modes for hypervisor
– e.g., VMEnter, VMExit in x86
• Memory virtualization – Nested paging
– Guest physical to machine translation by hardware
• I/O virtualization – Virtual I/O device (function) support by harware
» E.g., SR-IOV enabled network device
– Guest OS directly access hardware device
– I/O device memory access protection by IOMMU (I/O memory management unit)
• e.g., Intel VT-x, VT-d, AMD-V
14 SSE3044: Operating Systems | Fall 2015 | Jinkyu Jeong ([email protected])
Cloud Computing (1)
On-demand self-service
Ubiquitous network access • Anywhere, anytime, anydevice
Location-independent resource pooling
Rapid elasticity
Pay as you go
E.g., Amazon EC2, Microsoft Azure, Google AppEngine, …
15 SSE3044: Operating Systems | Fall 2015 | Jinkyu Jeong ([email protected])
Cloud Computing (2)
Service models
• IaaS (infrastructure as a service)
• PaaS (Platform as a service)
• SaaS (Software as a service)
Deployment models
• Private cloud
• Public cloud
• Hybrid cloud