Virtual Machine Monitor

Virtual Machine Monitor Applications Process I/O   Devices File  system Virtual  memory Network Operating  System Hardware Virtual  Machine  Monit...
Author: Virgil Black
2 downloads 0 Views 1MB Size
Virtual Machine Monitor Applications Process I/O   Devices

File  system

Virtual  memory Network

Operating  System

Hardware Virtual  Machine  Monitor CPU

December  8,  2016

Disk

EECS  482  – Lecture  26

RAM

1

What is a VMM? ●



OS  offers  illusion that  each  process  is  running   on  its  own  computer A  VMM virtualizes  an  entire  physical  machine ◆





VMM  offers  illusion that  OS  has  full  control  over  the   hardware VMM  “applications” (OSes)  run  in  virtual  machines

Implication:  Can  run  multiple  instances  of   different  OSes simultaneously  on  a  machine

December  8,  2016

EECS  482  – Lecture  26

2

Why do such a crazy thing? ●

Resource  utilization ◆





Software  use  and  development ◆





Machines  today  are  powerful,  multiplex  their  hardware » Example:  Cloud  services Migrate  VMs  across  machines  without  shutdown

Can  run  multiple  OSes simultaneously » No  need  to  dual  boot Can  do  system  (e.g.,  OS)  development  at  user-­level

Many  other  cool  applications ◆

Debugging,  emulation,  security,  fault  tolerance,  …

December  8,  2016

EECS  482  – Lecture  26

3

Example of Cool VMM Tricks ●

How  to  experiment  with  apps,  protocols,  and   systems  on  future  hardware? ◆



Example:  How  to  experiment  with  100  Gbps network?

Time  dilation ◆



VMM  slows  timer  interrupt  to  make  hardware  (CPU,   disk,  network)  appear  faster  to  OS  and  apps Example: » OS  reads  10  Gb  of  data  from  network  in  1  second,   but  thinks  only  0.1  second  has  elapsed » But,  applications  run  10x  slower

December  8,  2016

EECS  482  – Lecture  26

4

VMM Requirements ●

Fidelity ◆



Isolation ◆



OSes and  applications  work  without  modification » (although  we  may  modify  the  OS  a  bit)

VMM  protects  resources  and  VMs  from  each  other

Performance ◆

VMM  is  another  layer  of  software  à overhead » As  with  OS,  want  to  minimize  this  overhead

December  8,  2016

EECS  482  – Lecture  26

5

VMware Hypervisor Model Applications

Operating  System

Hardware Virtual  Machine  Monitor

Hardware

December  8,  2016

EECS  482  – Lecture  26

6

VMware Hosted Architecture

December  8,  2016

EECS  482  – Lecture  26

7

Xen Architecture

December  8,  2016

EECS  482  – Lecture  26

8

What needs to be virtualized? ●

Exactly  what  you  would  expect ◆ ◆ ◆ ◆



CPU Events Memory I/O  devices

Isn’t  this  just  duplicating  OS  functionality? ◆ ◆



Yes  and  no Approaches  will  be  similar  to  what  OS  does » Simpler  functionality  (VMM  much  smaller  than  OS) But  implements  a  different  abstraction » Hardware  interface  vs.  OS  interface

December  8,  2016

EECS  482  – Lecture  26

9

Virtualizing Memory ●

OS  assumes  full  control  over  memory



But  VMM  partitions  memory  among  VMs ◆



VMM  needs  to  control  mappings  for  isolation » OS  can  only  map  to  a  physical  page  given  to  it  by  VMM

Solution:  Need  MMU  support  to  handle  two-­levels  of   page  tables

December  8,  2016

EECS  482  – Lecture  26

10

Shadow Page Tables

December  8,  2016

EECS  482  – Lecture  26

11

Monitors for Synchronization ●





Lack  of  race  conditions  relies  on  correct  use  of   locks  and  condition  variables For  example,  must  remember  to  acquire   correct  lock  before  accessing  shared  set How  to  detect  improper  use  of  locks?

December  8,  2016

EECS  482  – Lecture  26

12

Dynamic analysis ●



Monitor  program’s   execution  to  detect   unsafe  access For  example,  detect   possible  simultaneous   access  using  happens-­ before relationship   between  synchronization   events December  8,  2016

EECS  482  – Lecture  26

13

Problem with happens-­before ●

Ability  to  detect  race   conditions  depends   on  interleavings   produced  by   scheduler

December  8,  2016

EECS  482  – Lecture  26

14

Eraser ●

Associate  every  variable  with  a  set  of  locks ◆





Initialize  to  union  of  all  locks

Whenever  the  variable  is  accessed  thereafter,   lockset  = lockset  ∩  set  of  locks  held  by  current   thread Race  condition  detected  if  lockset  becomes   empty    

December  8,  2016

EECS  482  – Lecture  26

15

Scheduling ●

Problems  with  scheduling  strategies  we’ve   discussed?



Priority?



Round  robin?



Trade-­off  between  responsiveness  and  fairness December  8,  2016

EECS  482  – Lecture  26

16

Priority Inversion x->Acquire()

PH x->Acquire() time

x->Release()

PL x->Acquire()

PH PM time

PL

December  8,  2016

x->Acquire()

EECS  482  – Lecture  26

17

Lottery Scheduling ●

● ●

Every  process/thread  is  assigned  some  number  of   lottery  tickets Winner  of  lottery  gets  access  to  resource Benefits? ◆ ◆ ◆



No  starvation Responsive:  can  dynamically  modify  ticket  allocation Easy  handling  of  priority  inversion  problem

Drawbacks? ◆ ◆

Complicates  the  policy of  ticket  allocation E.g.:  what  to  do  in  the  case  of  process  birth/death?

December  8,  2016

EECS  482  – Lecture  26

18