Introduction to Virtual Machines -...

33
Introduction to Virtual Machines Michael Jantz

Transcript of Introduction to Virtual Machines -...

Page 1: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Introduction to Virtual Machines

Michael Jantz

Page 2: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Acknowledgements

• Slides adapted from Chapter 1 in Virtual

Machines: Versatile Platforms for Systems

and Processes by James E. Smith and

Ravi Nair

• Credit to Prasad A. Kulkarni – some slides

were borrowed from his course on Virtual

Machines at the University of Kansas

2

Page 3: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Introduction to Virtual Machines

• Abstraction and interfaces

• Virtualization

• Computer system architecture

• Process virtual machines

• System virtual machines

3

Page 4: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Abstraction

• Mechanism to manage complexity in computer systems.

• Partitions design of a system into levels

• Allows higher levels to ignore the implementation details of lower levels

4

Page 5: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Interfaces

• Define the communication b/w two entities

• Hierarchical relationship

• Linear relationship

• Software can run on any machine supporting a compatible interface

5

PowerPC

MacOS

MacIntosh apps.

x86

Linux

Linux apps

x86

Windows

Windows apps.

Page 6: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Interfaces: Advantages

• Allows de-coupling of design tasks

• Work on different components can progress

independently

• Helps manage system complexity

• Each component provides an abstraction of

itself to the outside world

6

Page 7: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Interfaces: Disadvantages

• Limit flexibility• Developers must work within the constraints

of the interface

• Can be confining• ARM binaries on x86 machine?

• Windows applications on Linux?

7

MacOS

MacIntosh apps

x86 x86

Windows apps.

Linux

Page 8: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Interfaces: Disadvantages

• Inhibits innovation• Hard to change instruction sets

• Application software cannot directly exploit

microprocessor features

• Software is supposed to be architecture

independent!

8

Page 9: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Virtualization

• Map the interface of one system to a real

system that actually implements it

• Removes constraints imposed by interfaces

• Improves availability of application software

• Removes the assumption of a single regime,

improves security and failure isolation

• Provide a different view to a particular

computer resource

• Not necessarily a simpler view

9

Page 10: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Virtualization

• Creates an isomorphism that maps a virtual guest to a real host

10

Si S

Si' Sj'

Guest

Host

V(Si) V(Sj)

e(Si)

e'(Si')

j

Page 11: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Virtualization vs. Abstraction

• Virtualization does not necessarily hide details

11

filefile

virtualization

Page 12: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Virtual Machines

• Virtualization applied to the entire machine

• Adds a layer of software to a real machine

to support the desired architecture

• Process of virtualization

• Maps virtual resources or state to real

resources

• Uses real machine instructions to carry out

actions specified by the VM instructions

12

Page 13: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Benefits of VM's

• Flexibility

• Portability

• Isolation

• Security

13

Page 14: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Computer Architecture

• Architecture: functionality and appearance

of a computer system

• Implementation: embodiment of the

architecture

14

Page 15: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Computer Architecture

• Computer systems

consist of:

• Layers of abstraction

• Well-defined interfaces

15

I/O devices

and

Networking

System Interconnect

(bus)

Memory

Translation

Execution Hardware

Application

Programs

Main

Memory

Operating System

Libraries

Page 16: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

The ISA Interface

• Interface between

hardware & software

• Two parts

• System ISA

• User ISA

16

I/O devices

and

Networking

System Interconnect

(bus)

Memory

Translation

Execution Hardware

Application

Programs

Main

Memory

Operating System

Libraries

Page 17: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

The ISA Interface

• System ISA

• Important for OS

developers

17

I/O devices

and

Networking

System Interconnect

(bus)

Memory

Translation

Execution Hardware

Application

Programs

Main

Memory

Operating System

Libraries

Page 18: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

The ABI Interface

• Application Binary

Interface (ABI)

• User ISA + system calls

• Important for compiler

writers

18

I/O devices

and

Networking

System Interconnect

(bus)

Memory

Translation

Execution Hardware

Application

Programs

Main

Memory

Operating System

Libraries

Page 19: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

The API Interface

• Application

Programming

Interface (API)

• User ISA + library calls

• Important for

application

programmers

19

I/O devices

and

Networking

System Interconnect

(bus)

Memory

Translation

Execution Hardware

Application

Programs

Main

Memory

Operating System

Libraries

Page 20: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Major Program Interfaces

• ISA – supports all conventional software

• ABI – supports application software only

20

System Calls

User ISASystem ISAISA

Application Software

Operating System

System Calls

User ISASystem ISAABI

Application Software

Operating System

Page 21: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Process Virtual Machines

• Supports an individual process

• Run SW for a different OS and different ISA

• Couple at ABI level via runtime system

21

VirtualizingSoftware

Application Process

Machine

OS

Hardware

Guest

Runtime

Host

Application Process

Virtual

Machine

Page 22: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Process Virtual Machines

• Guest processes intermingle

with host processes

• Binaries encapsulated by

the runtime

• PVM does not include OS

• Examples:

• Java

• IA-32 EL

• Dynamic optimizers

(dynamo)

HOST OS

Disk

file sharing

network communication

guestprocess

create

host

process

guest

process

runtimeruntime

guest

process

runtime

host

process

22

Page 23: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

PVM: Multiprogramming

• OS provides PVMs for each application

• System calls + user ISA == PVM to

execute multiple, concurrent processes

• Each process is given the illusion of

having the entire machine to itself

23

Page 24: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

PVM: Emulators

• Execute binaries compiled for one ISA on a machine with a different ISA

• Emulation methods

• Interpretation• Fast startup, but slow steady-state

• Dynamic binary translation• High startup overhead, faster steady-state

• Uses a code cache to store translated blocks

• Examples: Java, IA32-EL

24

Page 25: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

PVM: Binary Optimizers

• Same source and target ISAs

• Main task is optimization

• ABI level optimization

• May also collect performance profiles

• May also enhance security

• e.g., HP's Dynamo

25

Page 26: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

PVM: High-Level Language VMs

• Designed for VM execution

• Aim to minimize HW- and OS-specific features

26

HLL Program

Intermediate Code

Memory Image

Object Code(ISA)

Compiler front-end

Compiler back-end

Loader

HLL Program

Portable Code( Virtual ISA )

Host Instructions

Virt. Mem. Image

Compiler

VM loader

VM Interpreter/Translator

Traditional HLL VM

Page 27: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

PVM: High-Level Language VMs

• Distribution format is binary class files

• Virtualized ISA (no real implementation)

• OS interaction via API

• Examples: Java, Micosoft CLI

27

Sparc

Workstation

Java Binary Classes

x86

PC

Apple

Mac

VM

implementation

VM

implementation

VM

implementation

Java VMArchitecture

Page 28: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

System Virtual Machines

• Supports an OS with many user-level processes

• Couple at the ISA level

• Examples: VMWare, Transmeta Crusoe

28

Hardware

"Machine"

OS

Applications

Virtualizing

SoftwareVirtual

Machine

OS

Applications

Guest

VMM

Host

Page 29: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Classic System Virtual Machine

• Original meaning of the term virtual machine

• All guest and host software use the same ISA

• VMM runs on bare hardware (privileged mode)

• VMM intercepts all privileged operations for the guest OS's

29

Linuxprocess

Winprocess

HOST PLATFORM

virtualnetwork communication

Guest OS (Windows)

Win

process

Winprocess

Guest OS2 (Linux)

VMM

Linuxprocess

Linuxprocess

Page 30: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Hosted VM

• VMM built on top of existing OS

• Advantages

• Installs just like a user-level application

• Host OS provides driver support

• Drawbacks

• Less efficient

30

Page 31: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Whole System VMs

• Host and guest do not use a common ISA

• Both app and OS code require emulation

• Typically implemented as a hosted VMM

• Example: VirtualPC

31

Page 32: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

Co-designed Virtual Machines

• Designed to enable innovative ISA's and/or

hardware implementations

• As if the VM software is part of the HW

• Applications / OS never directly execute native

ISA instructions

• Useful for backwards compatibility

• Example: Transmeta Crusoe

32

Page 33: Introduction to Virtual Machines - UTKweb.eecs.utk.edu/~mrjantz/slides/teaching/runtime_systems/intro_to… · OS Hardware Guest Runtime Host Application Process Virtual Machine.

VM Taxonomy

33