U5 - Virtual Machines
U5 - Virtual Machines
CONTENTS
• Overview
• Benefits and Features
• Building Blocks
• Types of Virtual Machines and Their Implementations
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
• (Except in the case of paravirtualization)
• Guest – process provided with virtual copy of the host
• Usually an operating system
• Single physical machine can run multiple operating systems concurrently, each in its own
virtual machine
OV E RV I E W
• Host system protected from VMs, VMs protected from each other
• i.e. A virus less likely to spread
• Sharing is provided though via shared file system volume, network communication
• Freeze, suspend, running VM
• Then can move or copy somewhere else and resume
• Snapshot of a given state, able to restore back to that state
• Some VMMs allow multiple snapshots per VM
• Clone by creating copy and running both original and copy
• Great for OS research, better system development efficiency
• Run multiple, different OSes on a single machine
• Consolidation, app dev, …
BENEFITS AND FEATURES (CONT.)
• How does switch from virtual user mode to virtual kernel mode occur?
• 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
• Known as trap-and-emulate
• Most virtualization products use this at least in part
• User mode code in guest runs at same speed as if not a guest
• But kernel mode privilege mode code runs slower due to trap-and-emulate
• Especially a problem when multiple guests running, each needing trap-and-emulate
• CPUs adding hardware support, mode CPU modes to improve virtualization
performance.
TRAP-AND-EMULATE VIRTUALIZATION IMPLEMENTATION
TYPES OF VIRTUAL MACHINES AND IMPLEMENTATIONS
• Does not fit the definition of virtualization – VMM not presenting an exact duplication
of underlying hardware
• But still useful!
• VMM provides services that guest must be modified to use
• Leads to increased performance
• Less needed as hardware support for VMs grows
• Xen, leader in para-virtualized space, adds several techniques
• For example, clean and simple device abstractions
• Efficient I/O
• Good communication between guest and VMM about device I/O
• Each device has circular buffer shared by guest and VMM via shared memory
TYPES OF VMS – EMULATION
• Another (older) way for running one operating system on a different operating system
• Virtualization requires underlying CPU to be same as guest was compiled for
• Emulation allows guest to run on different CPU
• Necessary to translate all guest instructions from guest CPU to native CPU
• Emulation, not virtualization
• Useful when host system has one architecture, guest compiled for other architecture
• Company replacing outdated servers with new servers containing different CPU architecture, but
still want to run old applications
• Performance challenge – order of magnitude slower than native code
• New machines faster than older machines so can reduce slowdown
• Very popular – especially in gaming where old consoles emulated on new