Professional Documents
Culture Documents
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on Si
lber
schat
z,Gal
vinandGagne©2018
Chapter 18: Virtual Machines
Over
view
Hi
stor
y
Benefi
tsandFeat
ures
Bui
l
dingBl
ocks
TypesofVi
rt
ualMachi
nesandThei
rImpl
ement
ati
ons
Vi
rt
ual
i
zat
ionandOper
ati
ng-
Syst
em Component
s
Exampl
es
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
2 Si
lber
schat
z,Gal
vinandGagne©2018
Chapter Objectives
Ex
plor
ethehi
st
oryandbenefi
tsofvi
rt
ualmachi
nes
Di
scusst
hevar
iousvi
rt
ual
machi
net
echnol
ogi
es
Des
cri
bet
hemet
hodsusedt
oimpl
ementv
irt
ual
i
zat
ion
Showt hemostc ommonhar
dwaref
eatur
esthats
upport
vi
rtual
izat
ionandexpl
ai
nhowtheyar
eus edbyoper
ati
ng-
system modules
Di
scusscur
rentvi
rt
ual
i
zat
ionr
esear
char
eas
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
3 Si
lber
schat
z,Gal
vinandGagne©2018
Overview
Fundamentalidea–abstr
acthar
dwar
eofasi
ngl
ecomput
eri
ntosever
al
di
)erentexecuti
onenvi
ronments
Si
mil
art
olayer
edappr
oach
Butl
ayercr
eat
esvi
rt
ualsyst
em (vi
rt ne,orVM)onwhi
ualmachi ch
oper
ati
onsyst
emsorappl
i
cationscanrun
Sever
alcomponent
s
Host–under
lyi
nghar
dwar
esyst
em
Vi
rt nemanager(
ualmachi VMM)orhyper sor–cr
vi eat
esandruns
vi
rt
ualmachi
nesbypr
ovi
di
ngint
erf
acet
hati
sident
icalt
othehost
(
Excepti
nthecaseofpar
avi
rt
ual
i
zat
i
on)
Guest–pr
ocesspr
ovi
dedwi
t
hvi
rt
ual
copyoft
hehost
Usual
l
yanoper
ati
ngsyst
em
Singl
ephysi
cal
mac hi
necanrunmul
t
ipl
eoper
ati
ngsyst
emsconcur
rent
l
y,
eachini
tsownvir
tual
machine
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
4 Si
lber
schat
z,Gal
vinandGagne©2018
System Models
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
5 Si
lber
schat
z,Gal
vinandGagne©2018
Implementation of VMMs
Var
ygr
eat
ly,wi
thopt
i
onsi
ncl
udi
ng:
Type0hyper vi
sors-Hardware-
basedsol
uti
onst
hatpr
ovide
suppor
tforvi
rt
ualmachi
necreati
onandmanagementvi
afirmwar
e
I
BM LPARsandOr
acl
eLDOMsar
eexampl
es
Type1hypervisors-Oper
ati
ng-
sys
tem-
li
kesof
twar
ebui
l
tto
provi
devi
rt
ual
i
zation
I
ncl
udi
ngVMwar
eESX,JoyentSmar
tOS,andCi
t
rixXenSer
ver
Type1hyper
visors–Alsoi
ncl
udesgeneral
-pur
poseoperat
ing
syst
emst
hatprovi
dest
andar
dfunct
ionsaswellasVMM f
unctions
I
ncl
udi
ngMi
crosof
tWi
ndowsSer
verwi
t
hHyper
VandRedHatLi
nux
wi
thKVM
Type2hypervi s-Appl
sor i
cati
onst
hatrunonstandar
doper
ati
ng
syst
emsbutprovi
deVMM f
eatur
estoguestoper
ati
ngsyst
ems
I
ncludei
ngVMwareWor
kst
ati
onandFusi
on,Par
all
elsDeskt
op,and
Oracl
eVirt
ual
Box
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
6 Si
lber
schat
z,Gal
vinandGagne©2018
Implementation of VMMs (cont.)
Ot
hervar
iat
i
onsi
ncl
ude:
Par
avirt
ual
izat
ion-Techni
quei
nwhicht
heguestoper
ati
ngsystem i
s
modi
fi
edtoworkincooper
ati
onwi
tht
heVMM toopti
mizeper
formance
Programming-envi
ronmentvi
rt
uali
zaton-VMMsdonotvi
i rt
ual
i
zer
eal
hardwar
ebutinst
eadcreat
eanopti
mizedvi
rt
ualsyst
em
UsedbyOr
acl
eJavaandMi
cros
oft
.Net
Emulat
ors–Al
l
owappli
cati
onswri
tt
enforonehardwar
eenvi
ronmentt
o
r
unonav er
ydi
)er
enthar
dwareenvi
ronment,suchasadi
)er
enttypeof
CPU
Appli
cati
oncont nment-Notvi
ai rt
ual
i
zat
ionatallbutr
atherpr
ovides
vi
rt
ual
izat
ion-
li
kefeat
uresbysegr
egati
ngappli
cati
onsfr
om theoperat
ing
sy
stem,makingthem moresecur
e,manageable
I
ncl
udi
ngOr
acl
eSol
ari
sZones,BSDJai
l
s,andI
BM AI
XWPARs
Muchvar
iat
ionduetobr
eadt
h,dept
handi
mpor
tanceofvi
rt
ual
i
zat
ioni
n
moder
ncomputing
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
7 Si
lber
schat
z,Gal
vinandGagne©2018
History
Fi
rstappear
edi
nIBM mai
nfr
amesi
n1972
Al
l
owedmul
t
ipl
euser
stos
har
eabat
ch-
ori
ent
edsy
stem
For
mal
defi
nit
i
onofvi
rt
ual
i
zat
i
onhel
pedmovei
tbeyondI
BM
1.AVMM pr
ovi
desanenvi
ronmentf
orpr
ogr
amst
hati
s
ess
ent
ial
l
yident
ic
alt
otheor
igi
nal
machi
ne
2.Pr
ogr
amsr
unni
ngwi
thi
nthatenvi
ronments
howonl
ymi
nor
per
for
mancedecr
eases
3.TheVMM i
sincompl
etecont
rolofsyst
em r
esour
ces
Inlate1990sI
ntelCPUsfastenoughf
orr
esear
cher
stot
ry
vir
tuali
zi
ngongeneralpur
posePCs
XenandVMwar
ecr
eat
edt
echnol
ogi
es,st
i
llusedt
oday
Vi
rt
ual
i
zat
ionhasexpandedt
omanyOSes
,CPUs,VMMs
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
8 Si
lber
schat
z,Gal
vinandGagne©2018
Benefits and Features
Hostsyst
em pr
otect
edf
rom VMs,VMspr
otect
edf
rom eachot
her
I
.e.Avi
rusl
essl
i
kel
ytospr
ead
Shari
ngi
sprovi
dedthoughv
iashar
edfi
l
esy
stem vol
ume,
net
workcommunicat
ion
Fr
eeze,suspend,r
unni
ngVM
Thencanmov
eorcopysomewher
eel
seandr
esume
Snapshotofagi
venst
ate,abl
etor
est
orebac
ktot
hatst
ate
SomeVMMsal
l
owmul
t
ipl
esnaps
hot
sperVM
onebycr
Cl eat
ingcopyandr
unni
ngbot
hor
igi
nalandcopy
Gr
eatf
orOSr
esear
ch,bet
ters
yst
em devel
opmenteBci
ency
Runmul
t
ipl
e,di
)er
entOSesonasi
ngl
emac
hine
Consol
idat
ion,appdev,…
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
9 Si
lber
schat
z,Gal
vinandGagne©2018
Benefits and Features (cont.)
Templat
ing–createanOS+appli
cati
onVM,provi
deitt
o
cust
omers,usei
ttocr
eat
emul
ti
pleinst
ancesoft
hatcombinat
i
on
Li
vemi
grat
ion–movear
unni
ngVM f
rom onehostt
oanot
her
!
Noi
nter
rupt
ionofuseracces
s
Al
lt
hosef
eat
urest
akent
oget
her-
>cl
oudcomput
ing
UsingAPIs,progr
amstel
lcl
oudinf
rast
ruct
ure(
servers,
networki
ng,st
orage)t
ocr
eatenewgues t
s,VMs,vi
rtual
desktops
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
10 Si
lber
schat
z,Gal
vinandGagne©2018
Building Blocks
Gener
all
ydi
Bcul
ttopr
ovi
deanexactdupl
i
cat
eofunder
lyi
ng
machi
ne
Especi
al
lyi
fonl
ydual
-modeoper
ati
onavai
l
abl
eonCPU
Butget
ti
ngeasierovert
i
measCPUf
eat
uresandsuppor
tfor
VMM improves
MostVMMsimplementvi
rtualCPU(VCPU)tor
epr
esent
st
ateofCPUperguestasguestbel
i
evesi
ttobe
Whenguestcont
extswi
tchedont
oCPUbyVMM,
i
nfor
mat
ionfr
om VCPUloadedandst
ored
Sever
alt
echni
ques,asdescr
ibedi
nnextsl
i
des
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
11 Si
lber
schat
z,Gal
vinandGagne©2018
Building Block – Trap and Emulate
DualmodeCPUmeansguestexecut
esi
nusermode
Ker
nelr
unsi
nker
nelmode
Notsaf
etol
etguestker
nel
runi
nker
nel
modet
oo
SoVM needst
womodes–vi
rt
ual
usermodeandvi
rt
ual
ker
nelmode
Bot
hofwhi
chr
uni
nrealus
ermode
Act
i
onsinguestthatusual
lycauseswi
tc
htok
ernel
mode
mustcauseswi
tchtovi
rtualker
nelmode
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
12 Si
lber
schat
z,Gal
vinandGagne©2018
Trap-and-Emulate (cont.)
Howdoesswi
t
chf
rom vi
rt
ual
usermodet
ovi
rt
ual
ker
nel
modeoccur
?
Att
empt
i
ngapr
ivi
l
egedi
nst
ruct
i
oni
nusermodecausesaner
ror-
>
t
rap
VMM gai
nscont
rol
,anal
yzeser
ror
,ex
ecut
esoper
ati
onas
at
tempt
edbyguest
Ret
urnscont
rol
toguesti
nusermode
Knownast
rap-
and-
emul
ate
Mostvi
rt
ual
i
zat
i
onpr
oduct
sus
ethi
satl
easti
npar
t
Usermodecodei
nguestr
unsatsamespeedasi
fnotaguest
Butk
ernel
modepr
ivi
l
egemodecoder
unssl
owerduet
otr
ap-
and-
emul
ate
Especial
l
yaprobl
em whenmul
t
ipl
eguest
srunni
ng,eachneedi
ng
t
rap-and-
emul
ate
CPUsaddinghar
dwaresuppor
t,modeCPUmodest
oimpr
ove
vi
rt
ual
i
zat
ionperf
ormance
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
13 Si
lber
schat
z,Gal
vinandGagne©2018
Trap-and-Emulate Virtualization Implementation
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
14 Si
lber
schat
z,Gal
vinandGagne©2018
Building Block – Binary Translation
SomeCPUsdon’thavecl
eans epar
ati
onbet
weenpr
ivi
l
eged
andnonpr
ivi
l
egedi
nst
ruct
ions
Ear
li
erI
ntelx86CPUsar
eamongt
hem
Ear
li
estI
ntel
CPUdesi
gnedf
orac
alcul
ator
Backwar
dcompat
ibi
l
it
ymeansdi
Bcul
ttoi
mpr
ove
Consi
derI
ntelx86popf i
nst
ruct
i
on
LoadsCPUKagsr
egi
sterf
rom cont
ent
soft
hest
ack
I
fCPUi
npr
ivi
l
egedmode-
>al
lKagsr
epl
aced
I
fCPUi
nusermode-
>onsomeKagsr
epl
aced
– Not
rapi
sgener
ated
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
15 Si
lber
schat
z,Gal
vinandGagne©2018
Binary Translation (cont.)
Ot
hers
imi
l
arpr
obl
em i
nst
ruct
ionswewi
l
lcal
lspeci
ali
nst
ruct
ions
Caus
edt
rap-
and-
emul
atemet
hodc
onsi
der
edi
mpossi
bl
eunt
il
1998
Bi
nar
ytr
ans
lat
ions
olvest
hepr
obl
em
Basi
csar
esi
mpl
e,buti
mpl
ement
ati
onver
ycompl
ex
1.I
fguestVCPUi
sinusermode,guestc
anr
uni
nst
ruct
ionsnat
ivel
y
2.I
fguestVCPUi
nker
nel
mode(
gues
tbel
i
evesi
ti
sinker
nel
mode)
1. VMM examineseveryins
truct
iongues
tisabouttoexecut
eby
r
eadi
ngaf ewinst
ruct
ionsaheadofprogram count
er
2. Non-
speci
al
-i
nst
ruct
i
onsr
unnat
i
vel
y
3. Speci
ali
nstr
uct
i
onstr
ans
latedi
ntonewsetofi
nst
ructi
onsthat
per
for
m equi
val
entt
ask(
forexampl
echangi
ngtheK agsi
nt he
VCPU)
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
16 Si
lber
schat
z,Gal
vinandGagne©2018
Binary Translation (cont.)
I
mpl
ement
edbyt
ransl
ati
onofcodewi
t
hinVMM
Codereadsnati
vei
nst
ruct
i
onsdynamical
lyf
rom guest
,ondemand,
gener
atesnat
ivebi
nar
ycodethatex
ecutesi
nplaceofori
gi
nalcode
Per
for
manceoft
hismet
hodwoul
dbepoorwi
t
houtopt
imi
zat
ions
Pr
oduct
sli
keVMwar
eusecachi
ng
Trans
lat
eonce,andwhenguestex ecut
escodecont
aini
ng
speci
ali
nst
ruct
ioncachedt
rans
lat
ionusedinst
eadof
tr
ansl
ati
ngagai
n
Test
ingshowedbootingWindowsXPasgues tcaused
950,
000transl
ati
ons,at3microsecondseach,or3second
(5%)s l
owdownov ernat
ive
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
17 Si
lber
schat
z,Gal
vinandGagne©2018
Binary Translation Virtualization Implementation
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
18 Si
lber
schat
z,Gal
vinandGagne©2018
Nested Page Tables
Memor
ymanagementanot
hergener
alchal
l
enget
oVMM i
mpl
ement
ati
ons
HowcanVMM keeppage-
tablestat
eforbot
hguest
sbeli
evi
ngt
heycont
rol
t
hepaget
abl
esandVMM t hatdoescontr
olt
hetabl
es?
Commonmet
hod(
fort
rap-
and-
emul
ateandbi
nar
ytr
ansl
ati
on)i
snest
ed
paget es(
abl NPTs)
Eachguestmai
ntai
nspaget
abl
est
otr
ans
lat
evi
rt
ual
tophysi
cal
addr
esses
VMM mai
ntai
nsperguestNPTst
orepr
esentguest
’
spage-
tabl
est
ate
J
ustasVCPUst
oresguestCPUst
ate
WhenguestonCPU-
>VMM makest
hatguest
’
sNPTst
heact
i
ves
yst
em
paget
abl
es
Guestt
ri
est
ochangepagetabl
e->VMM mak
esequi
val
entchanget
o
NPTsandit
sownpagetabl
es
Cancausemanymor
eTLBmi
sses-
>muchsl
owerper
for
manc
e
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
19 Si
lber
schat
z,Gal
vinandGagne©2018
Building Blocks – Hardware Assistance
Al
lvi
rt
ual
i
zat
i
onneedssomeHW suppor
t
Mor
esuppor
t->mor
efeat
urer
ich,s
tabl
e,bet
terper
for
manceofgues
ts
I
nteladdednewVT-xi
nst
ruct
i
onsi
n2005andAMDt
heAMD-
V
i
nstr
ucti
onsin2006
CPUswi
tht
hesei
nst
ruct
ionsr
emoveneedf
orbi
nar
ytr
ansl
ati
on
Gener
all
ydefinemor
eCPUmodes–“
guest
”and“
host
”
VMM canenabl
ehostmode,definechar
act
eri
sti
csofeachguestVM,
swi
tcht
oguestmodeandguest(s)onCPU(s)
I
nguestmode,guestOSthinksiti
srunni
ngnat
ivel
y,seesdevi
ces(
as
definedbyVMM f
ort
hatguest)
Accesst
ovi
rt
ual
i
zeddevi
ce,pr
ivi
nst
ruct
ionscauset
rapt
oVMM
CPUmai
ntai
nsVCPU,cont
extswi
tchesi
tasneeded
HW suppor
tforNest
edPageTabl
es,DMA,i
nter
rupt
saswel
lovert
i
me
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
20 Si
lber
schat
z,Gal
vinandGagne©2018
Nested Page Tables
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
21 Si
lber
schat
z,Gal
vinandGagne©2018
Types of Virtual Machines and Implementations
Manyvar
iat
i
onsaswel
lasHW det
ail
s
AssumeVMMst
akeadvant
ageofHW f
eat
ures
HW f
eat
urescansi
mpl
i
fyi
mpl
ement
ati
on,i
mpr
oveper
for
mance
What
evert
het
ype,aVM hasal
i
fecycl
e
Cr
eat
edbyVMM
Resour
cesassi
gnedtoit(
numberofcor
es,amountofmemor
y,
net
worki
ngdet
ail
s,st
oragedet
ail
s)
I
ntype0hyper
visor
,resour
cesusual
l
ydedi
cat
ed
Ot
hert
ypesdedi
cat
eorshar
eresour
ces,orami
x
Whennol
ongerneeded,VM canbedel
eted,f
reei
ngr
esouces
St
epssi
mpl
er,f
ast
ert
hanwi
t
haphysi
cal
machi
nei
nst
all
Canleadtovirt
ualmachi awlwi
nespr t
hlot
sofVMs,hi
st
oryand
st
atediBcul
ttotr
ack
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
22 Si
lber
schat
z,Gal
vinandGagne©2018
Types of VMs – Type 0 Hypervisor
Ol
didea,undermanynamesbyHW manuf
act
urer
s
“
par
ti
ti
ons
”,“
domai
ns”
AHW f
eat
urei
mpl
ement
edbyfir
mwar
e
OSneedt
onot
hingspec
ial
,VMM i
sinfi
rmwar
e
Smal
l
erf
eat
uresett
hanot
hert
ypes
Eachguesthasdedi
cat
edHW
I
/O achal
l
engeasdiBcul
ttohaveenoughdevi
ces
,cont
rol
l
erst
o
dedi
catet
oeachguest
Someti
mesVMM implement
sacont
rolpar
ti
tonr
i unni
ng
daemonst
hatot
herguest
scommuni
cat
ewithf
orshar
edI/
O
Canpr
ovi
devir
tual
izat
i
on-
wit
hin-
vir
tual
i
zat
i
on(
guesti
t
sel
fcanbe
aVMM wi
thguests
Ot
hert
ypeshavedi
Bcul
t
ydoi
ngt
his
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
23 Si
lber
schat
z,Gal
vinandGagne©2018
Type 0 Hypervisor
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
24 Si
lber
schat
z,Gal
vinandGagne©2018
Types of VMs – Type 1 Hypervisor
Commonl
yfoundi
ncompanydat
acent
ers
I
nasensebecomi
ng“
dat
acent
eroper
ati
ngsyst
ems”
Datac
entermanager
scont
rolandmanageOSesinnew,
sophi
sti
cat
edwaysbycont
roll
i
ngtheType1hyper
visor
Consol
i
dat
ionofmul
ti
pl
eOSesandappsont
olessHW
Moveguest
sbet
weensy
stemst
obal
anceper
for
mance
Snapshot
sandc
loni
ng
Spec
ialpur
poseoper
ati
ngsy
stemst
hatr
unnat
ivel
yonHW
Rat
hert
hanpr
ovi
dingsy
stem cal
li
nter
face,cr
eat
erunandmanageguest
OSes
Canr
unonTy
pe0hyper
vis
orsbutnotonot
herType1s
Runi
nker
nelmode
Guest
sgener
all
ydon’
tknowt
heyar
erunni
ngi
naVM
I
mpl
ementdevi
cedr
iver
sforhostHW becaus
enoot
hercomponentcan
Al
soprovi
deothert
radi
ti
onalOSser
vicesl
i
keCPUandmemor
y
management
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
25 Si
lber
schat
z,Gal
vinandGagne©2018
Types of VMs – Type 1 Hypervisor (cont.)
Anot
hervari
ati
onisagener
alpur
poseOSt
hatal
sopr
ovi
des
VMM funct
i
onali
ty
RedHatEnterpr
iseLi
nuxwi
t
hKVM,Wi
ndowswi
thHyper
-V,
Oracl
eSolari
s
Per
for
m nor
maldut
i
esaswel
lasVMM dut
i
es
Typi
cal
l
ylessf
eat
urer
icht
handedi
cat
edType1hyper
visor
s
I
nmanyways,t
reatguest
sOSesasj
ustanot
herpr
oces
s
Albei
twi
thspecial
handl
i
ngwhenguestt
ri
est
oexec
ute
speci
ali
nst
ruct
ions
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
26 Si
lber
schat
z,Gal
vinandGagne©2018
Types of VMs – Type 2 Hypervisor
Lessi
nter
est
ingf
rom anOSper
spect
ive
Ver
yli
tt
leOSi
nvol
vementi
nvi
rt
ual
i
zat
i
on
VMM i
ssi
mpl
yanot
herpr
oces
s,r
unandmanagedbyhost
Eventhehostdoesn’
tknowt
heyar
eaVMM r
unni
ng
guest
s
Tendtohavepoor
erover
all
perf
ormancebecausecan’
ttake
advant
ageofsomeHW feat
ures
Butal
soabenefi
tbec
auser
equi
renochangest
ohostOS
St
udentcoul
dhaveType2hypervi
soronnat
ivehost
,run
mult
ipl
eguest
s,allonst
andar
dhostOSsuchas
Windows,Li
nux,MacOS
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
27 Si
lber
schat
z,Gal
vinandGagne©2018
Types of VMs – Paravirtualization
Doesnotfitt
hedefini
t
ionofvi
rt
ual
i
zat
ion–VMM notpr
esent
i
ngan
exactdupl
i
cati
onofunderly
inghar
dware
Butst
i
llus
eful
!
VMM pr
ovi
dess
erv
icest
hatguestmustbemodi
fi
edt
ouse
Leadst
oinc
reas
edper
for
manc
e
Les
sneededashar
dwar
esuppor
tforVMsgr
ows
Xen,l
eaderi
npar
avi
rt
ual
i
zedspace,addss
ever
alt
echni
ques
Forexampl
e,cl
eanands
impl
edev
iceabst
ract
i
ons
EBci
entI
/O
Goodcommuni
cat
i
onbet
weenguestandVMM about
devi
ceI
/O
Eachdevi
cehasci
rcul
arbu)ershar
edbyguestandVMM
vi
asharedmemory
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
28 Si
lber
schat
z,Gal
vinandGagne©2018
Xen I/O via Shared Circular Buffer
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
29 Si
lber
schat
z,Gal
vinandGagne©2018
Types of VMs – Paravirtualization (cont.)
Xen,l
eaderi
npar
avi
rt
ual
i
zedspace,addssev
eral
techni
ques
(Cont
.)
Memor
ymanagementdoesnoti
ncl
udenes
tedpaget
abl
es
Eachguesthasownr
ead-
onl
ytabl
es
Guestuseshyper l(
cal cal
ltohyper
visor
)whenpage-
t
abl
echangesneeded
Parav
irt
ual
izat
ionall
owedvi
rt
uali
zat
i
onofol
derx86CPUs(
and
ot
hers)wit
houtbinar
ytr
ansl
ati
on
Guesthadt
obemodi
fi
edt
ous
erunonpar
avi
rt
ual
i
zedVMM
Butonmoder nCPUsXennolongerr
equi
resguestmodi
ficat
ion
->nolongerpar
avi
rt
ual
i
zat
ion
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
30 Si
lber
schat
z,Gal
vinandGagne©2018
Types of VMs – Programming Environment Virtualization
Al
sonot
-real
l
y-vi
rt
ual
i
zat
i
onbutus
ings
amet
echni
ques,pr
ovi
di
ng
si
mil
arf
eatur
es
Pr
ogramminglanguagei
sdesi
gnedt
orunwi
t
hinc
ust
om-
bui
l
t
vi
rt
ual
izedenv
ironment
ForexampleOracl
eJavahasmanyfeat
urest
hatdependon
runni
nginJavaVir
t ne(
ualMachi JVM)
Inthi
scasev i
rt
ual
izat
ioni
sdefinedaspr ovi
di
ngAPIsthatdefinea
setoffeat
uresmadeavailabl
etoal anguageandprogr
amswr it
ten
i
nthatlanguagetoprovi
deani mprovedexecut
ionenvi
ronment
JVM compil
edtor
unonmanys
yst
ems(
inc
ludi
ngsomesmar
t
phoneseven)
Pr
ogramswr
it
teni
nJavar
uni
ntheJVM nomat
tert
heunder
lyi
ng
sy
stem
Si
mil
art
oint
erpr
etedl
anguages
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
31 Si
lber
schat
z,Gal
vinandGagne©2018
Types of VMs – Emulation
Anot
her(ol
der
)wayf
orr
unni
ngoneoper
ati
ngs
yst
em onadi
)er
ent
oper
ati
ngsyst
em
Vir
tual
i
zat
ionr
equi
resunder
lyi
ngCPUt
obesameasguestwas
compil
edf
or
Emul
ati
onal
l
owsguestt
orunondi
)er
entCPU
Neces
sar
ytot
ransl
ateal
lguesti
nst
ruct
i
onsf
rom guestCPUt
onat
i
ve
CPU
Emul
ati
on,notvi
rt
ual
i
zat
i
on
Usef
ulwhenhos
tsyst
em hasonear
chi
t
ect
ure,guestcompi
l
edf
orot
her
ar
chi
tect
ure
Companyr
epl
acingoutdat
eds er
verswit
hnewser
ver
scontai
ni
ng
di
)er
entCPUarchi
tect
ure,butst
il
lwanttor
unol
dappl
icat
i
ons
Per
for
mancechal
l
enge–or
derofmagni
t
udes
lowert
hannat
i
vecode
Newmachi
nesf
ast
ert
hanol
dermac
hinessocanr
educesl
owdown
Ver
ypopul
ar–espec
ial
l
yingami
ngwher
eol
dconsol
esemul
atedon
new
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
32 Si
lber
schat
z,Gal
vinandGagne©2018
Types of VMs – Application Containment
Somegoal
sofvi
rt
ual
izati
onaresegr
egat
ionofapps,per
for
manceand
r
esour
cemanagement,easyst
art
,st
op,move,andmanagementofthem
Candot
hoset
hingswi
t
houtf
ull
-Kedgedvi
rt
ual
i
zat
i
on
Ifappl
i
cat
ionscompi
ledfort
hehostoper
ati
ngsyst
em,don’
tneedf
ull
vir
tual
i
zat
i
ont omeetthesegoal
s
Oracl
econt
ai s/zonesf
ner orexampl
ecr
eat
evi
rt
ual
layerbet
weenOS
andapps
Onl
yoneker
nel
runni
ng–hostOS
OSanddevi
cesarevi
rt
ual
ized,provi
dingr
esour
ceswi
t
hinzonewi
t
h
i
mpr
essi
onthatt
heyareonlyprocessesonsyst
em
Eachzonehasitsownappli
cat
i
ons;net
wor
kingst
ack,addr
esses,
andport
s;useraccount
s,et
c
CPUandmemor
yresour
cesdi
vi
dedbet
weenzones
Zonecanhavei
t
sownschedul
ert
ous
ethoser
esour
ces
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
33 Si
lber
schat
z,Gal
vinandGagne©2018
Solaris 10 with Two Zones
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
34 Si
lber
schat
z,Gal
vinandGagne©2018
Virtualization and Operating-System Components
Nowl
ookatoper
ati
ngsyst
em aspect
sofvi
rt
ual
i
zat
i
on
CPUs chedul
i
ng,memorymanagement
,I/
O,s
tor
age,and
uni
queVM mi gr
ati
onf
eat
ure
HowdoVMMss chedul
eCPUus
ewhenguest
sbel
i
eve
t
heyhavededi
catedCPUs?
Howcanmemorymanagementworkwhenmanyguest
s
r
equi
rel
argeamount
sofmemory?
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
35 Si
lber
schat
z,Gal
vinandGagne©2018
OS Component – CPU Scheduling
Evensi
ngl
e-CPUs
yst
emsactl
i
kemul
t
ipr
oces
soroneswhen
vi
rt
ual
i
zed
Oneormor
evi
rt
ualCPUsperguest
General
l
yVMM hasoneormor
ephys
ical
CPUsandnumberof
t
hreadstor
unonthem
Guest
sconfi
gur
edwi
thcer
tai
nnumberofVCPUs
Canbeadj
ust
edt
hroughoutl
i
feofVM
WhenenoughCPUsf oral
lguest
s->VMM c anall
ocat
ededicat
ed
CPUs,eachguestmuchli
kenat
iveoper
ati
ngs yst
em managi
ngits
CPUs
Usual
l
ynotenoughCPUs-
>CPUover
commi
tment
VMM canusest
andar
dsc
hedul
i
ngal
gor
it
hmst
oputt
hreadson
CPUs
Someaddf
air
nessaspec
t
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
36 Si
lber
schat
z,Gal
vinandGagne©2018
OS Component – CPU Scheduling (cont.)
Cycl
esteal
i
ngbyVMM andover
subscr
ipt
i
onofCPUsmeans
gues
tsdon’
tgetCPUcycl
est
heyexpect
Considerti
meshari
ngschedul
erinagues
ttryi
ngto
schedule100mstimesl
ices->eachmaytake100ms,1
second,orlonger
Poorr
esponset
i
mesf
oruser
sofguest
Ti
me-
of-
daycl
ocksi
ncor
rect
SomeVMMspr ovi
deappl
i
cat
iontorunineachguestt
ofix
t
ime-
of-
dayandprovi
deot
herint
egr
ati
onfeat
ures
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
37 Si
lber
schat
z,Gal
vinandGagne©2018
OS Component – Memory Management
Al
sosu)er
sfr
om over
subsc
ript
i
on-
>requi
resext
ramanagement
eBci
encyf
rom VMM
Forexampl
e,VMwar
eESXguest
shaveaconfi
gur
edamountofphy
sic
al
memory,t
henESXuses3met
hodsofmemorymanagement
1. Doubl
e- pagi
ng,i
nwhi
cht
heguestpaget
abl
eindic
atesapagei
sin
aphysicalfr
amebutt
heVMM movessomeofthosepagest
o
backi
ngs tor
e
2. Instal
lapseudo-
devi
cedrveri
i neachguest(
itlooksl
i
keadevi
ce
drivert
othegues
tker
nel
butreal
lyj
ustaddskernel-
modecodet
o
theguest)
Baloonmemor
l ymanagerc ommunicat
eswithVMM andistol
d
t
oallocat
eordeall
ocatememorytodecreaseori
ncr
ease
physi
calmemoryus eofguest
,causi
ngguestOStofreeorhave
morememoryav ai
labl
e
3. Dedupli
cat
ionbyVMM det
ermi
ni
ngifsamepageloadedmoret
han
once,memorymappi
ngthesamepageint
omulti
pleguest
s
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
38 Si
lber
schat
z,Gal
vinandGagne©2018
OS Component – I/O
Easierf
orVMMst
oint
egr
atewi
t
hgues
tsbecaus
eI/
O hasl
otsof
var
iati
on
Al
readysomewhatsegr
egat
ed/Kexi
blevi
adevi
cedr
iver
s
VMM canpr
ovi
denewdevi
cesanddevi
cedr
iver
s
Butov
eral
lI
/Oi
scompl
i
cat
edf
orVMMs
Manyshor
tpat
hsf
orI
/Oi
nst
andar
dOSesf
ori
mpr
ovedper
for
mance
Lesshyper
visorneedst
odof
orI
/Of
orguest
s,t
hebet
ter
Possi
bil
it
i
esincl
udedi
rectdevi
ceacc
ess,DMApass-
thr
ough,di
rect
i
nter
ruptdel
i
very
Agai
n,HW suppor
tneededf
ort
hes
e
Net
wor
kingal
socompl
exasVMM andguest
sal
lneednet
wor
kac
ces
s
VMM canbr
idgeguestt
onet
wor
k(al
l
owi
ngdi
rec
taccess
)
And/orpr
ovi
denet
wor
kaddr
esst
ransl
aton(
i NAT)
NATaddr
esslocalt
omachineonwhichguestisr
unni
ng,VMM
pr
ovi
desaddr
esstrans
lat
i
ontoguesttohi
deitsaddr
ess
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
39 Si
lber
schat
z,Gal
vinandGagne©2018
OS Component – Storage Management
Bot
hbootdi
skandgener
aldat
aacces
sneed bepr
ovi
dedbyVMM
Needtosupportpot
ent
ial
l
ydozensofgues
tsperVMM (
sost
andar
d
di
skpart
i
ti
oningnotsuBci
ent
)
Type1–s t
orageguestr
ootdi
sksandconfi
ginf
ormat
i
onwi
thi
nfi
l
e
syst
em pr
ovi
dedbyVMM asadi skimage
Type2–s
tor
easfi
l
esi
nfi
l
esy
stem pr
ovi
dedbyhostOS
Dupl
i
cat
efil
e->cr
eat
enewgues
t
Mov
efi
l
etoanot
hersyst
em -
>mov
eguest
Physi
cal
-t
o-vi
rual(
t P-t
o-V)conv
ertnat
ivedi
skbl
ocksi
ntoVMM
f
ormat
Vi
rtual
-t
o- cal(
physi V-t
o-P)conver
tfr
om v
irt
ual
for
matt
onat
iveor
di
skfor
mat
VMM alsoneedst
oprovi
deaccesstonet
workat
tacheds tor
age(
just
net
worki
ng)andot
herdiski
mages,dis
kpart
i
ti
ons,disks,etc
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
40 Si
lber
schat
z,Gal
vinandGagne©2018
OS Component – Live Migration
Taki
ngadvant
ageofVMM f
eatur
esl
eadst
onewfunc
tional
i
tynotf
oundon
gener
aloper
ati
ngsys
temssuchasl
i
vemigr
ati
on
Runningguestcanbemovedbet
weensy
stems,wi
thouti
nter
rupt
i
nguser
accesstot
heguestori
tsapps
Ver
yusef
ulf
orr
esour
cemanagement
,mai
ntenancedownt
imewi
ndows
,et
c
1. Thesour
ceVMM es
tabl
i
shesaconnec
tionwi
tht
het
argetVMM
2. Thet
argetcr
eat
esanewguestbyc
reat
i
nganewVCPU,et
c
3. Thesour
cesendsal
lread-
onl
yguestmemor
ypagest
othet
arget
4. Thesour
cesendsal
lread-
wri
t
epagest
othet
arget
,mar
kingt
hem ascl
ean
5. Thesour
cer
epeat
sst
ep4,asdur
ingt
hatst
epsomepageswer
epr
obabl
y
modi
fi
edbyt
hegues
tandar
enowdi
rt
y
6. Whenc
ycl
eofst
eps4and5becomesv
erys
hor
t,sour
ceVMM f
reezes
guest
,sendsVCPU’sfi
nal
s t
ate,sendsotherst
atedet
ail
s,sendsfinal
dir
ty
pages,andt
ell
star
gett
ostartrunni
ngtheguest
Onc
etar
getack
nowl
edgest
hatguestr
unni
ng,sour
cet
ermi
nat
esguest
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
41 Si
lber
schat
z,Gal
vinandGagne©2018
Live Migration of Guest Between Servers
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
42 Si
lber
schat
z,Gal
vinandGagne©2018
Examples - VMware
VMwar
eWor
kst
ati
onr
unsonx
86,pr
ovi
desVMM f
orguest
s
Runsasappl
icat
iononot
hernat
i
ve,i
nst
all
edhostoper
ati
ng
syst
em -
>Type2
Lotsofguest
spossi
ble,i
ncludi
ngWi ndows,Li
nux
,et
cal
l
runnabl
econcur
rent
l
y( asresourcesall
ow)
Vi
rtual
izat
i
onlayerabst
ract
sunderl
yi
ngHW,pr ovi
di
ngguest
wi
thisownv i
rtualCPUs,memory,di
skdr
ives,net
work
i
nterf
aces,et
c
Physi
caldi
skscanbeprovi
dedt
oguest
s,orv
irt
ualphysi
cal
di
sks(j
ustfi
l
eswit
hinhostfi
l
esy
stem)
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
43 Si
lber
schat
z,Gal
vinandGagne©2018
VMware Workstation Architecture
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
44 Si
lber
schat
z,Gal
vinandGagne©2018
Examples – Java Virtual Machine
Exampl
eofpr
ogr
ammi
ng-
env
ironmentvi
rt
ual
i
zat
i
on
Verypopul
arl
anguage/appl
i
cat
i
onenv
ironmenti
nvent
edbySun
Micr
osyst
emsin1995
Wr
it
eonce,r
unanywher
e
I
ncl
udesl
anguagespeci
fi
cat
ion(
Java)
,APIl
i
brar
y,Javav
irt
ual
machi
ne(
JVM)
Javaobj
ect
sspeci
fi
edbycl
asscons
truc
t,Javapr
ogr
am i
soneor
moreobj
ect
s
EachJavaobjectcompi
l
edintoar
chit
ect
ure-neut
ralbyt
ecode
out
put(.class)whichJVM cl
assloaderloads
JVM compi
l
edperar
chi
tect
ure,r
eadsbyt
ecodeandex
ecut
es
I
ncl
udesgar
bagecol
lect
iont
orecl
ai
m memor
ynol
ongeri
nuse
Madefast
erbyjust
-i
n-t
ime(JIT)compi
l
ert
hatt
urnsbyt
ecodes
i
ntonat
ivecodeandcachest
hem
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
45 Si
lber
schat
z,Gal
vinandGagne©2018
The Java Virtual Machine
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
46 Si
lber
schat
z,Gal
vinandGagne©2018
Virtualization Research
Ver
ypopul
art
echnol
ogywi
t
hact
i
ver
esear
ch
Dr
ivenbyusessuchasser
verconsol
i
dat
i
on
Uni
ker s,bui
nel l
tonl
ibr
aryoper
ati
ngsyst
ems
Ai
mtoi
mpr
oveeBci
encyandsecur
it
y
Special
i
zedmachineimagesusingoneaddressspace,shr
inki
ngat
tack
sur
faceandresourcef
ootpr
intofdepl
oyedappl
icat
i
ons
I
nessence,compi
leappli
cat
ion,l
i
brar
iescal
led,andusedker
nel
ser
vices
i
ntosi
ngl
ebinaryt
hatrunsinavir
tual
envir
onment
Bet
tercont
rol
ofpr
ocessesavai
l
abl
evi
apr
oject
sli
keQuest
-V
Real
ti
meexecut
i
onandf
aul
ttol
erancevi
avi
rt
ual
i
zat
i
oni
nst
ruct
i
ons
Part
i
ti
oni
nghypervi
sorspart
i
ti
onphysi
cal
r esour
cesamongstguest
s,f
ull
y-
commit
ti
ngal
lresour
ces(rat
hert
hanovercommitti
ng)
ForexampleaLi nuxsyst
em t
hatl
acksreal
-t
imecapabil
it
i
esforsaf
ety-and
secur
it
y-cr
it
ical
taskscanbeextendedwit
hal i
ght
weightreal
-t
imeOS
runni
nginit
sownVM
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
47 Si
lber
schat
z,Gal
vinandGagne©2018
Virtualization Research (cont.)
Separ
ati
onhyper
visor
sli
keQuest
-V,eac
htaskr
unsi
navi
rt
ualmachi
ne
Hypervi
sori
ni
ti
al
izessyst
em andst
art
stas
ksbutnoti
nvol
vedi
n
cont
inui
ngoper
ati
on
EachVM hasi
tsownr
esour
cest
het
askmanages
Taskscanber
eal
ti
meandmor
esecur
e
Ot
herexampl
esar
eXt
rat
um,Si
emensJ
ail
house
Canbui
l
dchi
p-l
evel
dist
ri
but
edsyst
em
Secur
eshar
edmemor ychannel
simpl
ement
edvi
aext
endedpage
t
abl
esfori
nter
-t
askcommunicat
ion
Pr
ojectt
arget
sincl
uder
obot
i
cs,sel
f
-dr
ivi
ngc
ars,I
nter
netofThi
ngs
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on 18.
48 Si
lber
schat
z,Gal
vinandGagne©2018
End of Chapter 18
Oper
ati
ngSyst
em Concept
s–10th Edi
ti
on Si
lber
schat
z,Gal
vinandGagne©2018