KVM Architecture Oerie! 2015 Edition
Stefan Hajnoczi >
"ntro#ucin$ KVM irtua%ization KVM hyer!isor r"ns !irt"a# machines on $in"% hosts ●
Mat"re on %&'( recent ro)ress on *+M and c
Most o"#ar and ,est s"orted hyer!isor on -enStac ●
htts/ii.oenstac.or) htts/ii. oenstac.or)iiHyer!i iiHyer!isorS"ortM sorS"ortMatri% atri%
"i#t in to +ed Hat Enterrise $in"% ●
3"mranet start" created KVM( joined +ed Hat in 200&
Virtua%ization $oa%& Efficient#y and sec"re#y r"nnin) !irt"a# machines on a $in"% host ●
●
$in"%( indos( etc )"est oeratin) systems *ccess to netorin) and stora)e in a contro##ed fashion $in"% )"est
indos )"est
Host 7et
6is
'here #oe& KVM fit into the &tac() Mana)ement for datacenters and c#o"ds
Mana)ement for one host
-enStac
+HEV
#i,!irt 3M;
Em"#ation for one )"est
Host hardare access and reso"rce m)mt
3EM:
9"est
Host erne# !m.o
More on *+M an# (-.(o
Virt"a#ization feat"res
6e!ice em"#ation
3EM:
+*M ... 3$ )f% card
$i!e mi)ration ... V7 remote dis#ay
!irtio=,# dis
Stora)e mi)ration
?nte# VM 9"esthost mode sitchin) ?n=erne# 6e!ice em"#ation Host erne#
!m.o
Har#!are irtua%ization &u//ort !ith "nte% VM *##os safe )"est code e%ec"tion at nati!e seed ●
ertain oerations tra o"t to the hyer!isor VM-7 VM+ES:ME
Host mode
VM$*:7H
Guest mode
VME?
Me-ory irtua%ization !ith "nte% + E%tended ;a)e a,#es BE;C add a #e!e# of address trans#ation for )"est hysica# memory. 9"est ;a)e a,#e Host ;a)e a,#e ;hysica# +*M
9"est memory address
Ho! *+M u&e& (-.(o 3EM: "sersace rocess "ses !m.o dri!er to e%ec"te )"est code/
open("/dev/kvm") ioctl(KVM_CREATE_VM) ioctl(KVM_CREATE_VCPU) for (;;) ioctl(KVM_RU!) #itc$ (e%it_re&on) c&e KVM_E'T_* /+ ,,, +/ c&e KVM_E'T_-.T* /+ ,,, +/
*+M /roce&& -o#e% 3EM: is a "sersace rocess 9"est +*M
:nri!i#e)ed and iso#ated "sin) SE$in"% for sec"rity
3EM:
Each KVM !;: is a thread
Host erne#
Host erne# sched"#er decides hen !;:s r"n
3inu4 conce/t& a//%y to *+MKVM Since 3EM: is a "sersace rocess( the "s"a# $in"% too#s or/ sB1C( toB1C( etc see 3EM: rocesses and threads tcd"mB&C sees ta netor traffic ,#traceB&C sees dis ?- re"ests Systema and erf see 3EM: acti!ity etc
Architecture +ent7#rien -u%ti7threa#e# E!ent #oos are "sed for timers( fi#e descritor monitorin)( etc ●
7on=,#ocin) ?-
●
a##,acs or coro"tines
M"#ti=threaded architect"re ,"t ith ,i) #oc ●
●
●
V;: threads e%ec"te in ara##e# Secific tass that o"#d ,#oc e!ent #oo are done in threads( e.). remote dis#ay encodin)( +*M #i!e mi)ration or( !irtio=,# data#ane( etc +est of 3EM: code r"ns "nder )#o,a# m"te%
Architecture +-u%ate# an# /a&&7throu$h #eice& 9"est sees ;:( +*M( dis( etc #ie on rea# machines ●
:nmodified oeratin) systems can r"n
●
;ara!irt"a#ized de!ices for ,etter erformance
Most de!ices are em"#ated and not rea# ●
?so#ation from host for sec"rity
●
Sharin) of reso"rces ,eteen )"ests
;ass=thro")h ;? adaters( diss( etc a#so ossi,#e ●
6edicated hardare
Architecture Ho&t$ue&t #eice e-u%ation &/%it 9"est de!ice F de!ice mode# !isi,#e to )"est rt#&14D
?nte# e1000
!irtio=net
6eco"#es hardare em"#ation from ?- mechanism ta
$2;!4
socet
Host de!ice F erforms ?- on ,eha#f of )"est
Architecture irtio #eice& KVM im#ements !irtio de!ice mode#s ●
net( ,#( scsi( seria#( rn)( ,a##oon
●
See htt/docs.oasis=oen.or)!irtio for secs
-en standard for ara!irt"a#ized ?- de!ices +ed Hat contri,"tes to $in"% and indos )"est dri!ers
Architectura% e4ce/tion ho&t in7(erne% #eice& Most de!ice em"#ation is ,est done in "sersace ●
Some *;?s or erformance feat"res on#y a!ai#a,#e in host erne#
!host dri!ers em"#ate !irtio de!ices in host erne# ●
●
!hostGnet.o hi)h=erformance !irtio=net em"#ation taes ad!anta)e of erne#=on#y zero=coy and interr"t hand#in) feat"res -ther de!ices co"#d ,e de!e#oed in theory( ,"t "s"a##y "sersace is a ,etter choice
Stora$e in *+M #oc dri!ers fa## in to cate)ories/ Iormats F ima)e fi#e formats Bco2( !md( etcC co2
ra
ra=osi%
r,d BehC
;rotoco#s F ?- transorts B;-S? fi#e( r,deh( etcC
;#"s additiona# ,#oc dri!ers that interose #ie "or"m( ,#de,")( ,#!erify
Stora$e &tac( *#ication VIS
9"est F a#ication #"s f"## fi#e system and ,#oc #ayer
#oc #ayer Iormat ;rotoco# VIS
3EM: F ima)e format( stora)e mi)ration( ?- thrott#in) Host F f"## fi#e system and ,#oc #ayer
#oc #ayer 6is
eare do",#e cachin) and anticiatory sched"#in) de#aysJ
'a%(throu$h irtio7b%( #i&( rea# re8ue&t 9art 1: 1. 9"est fi##s in re"est descritors
2. 9"est rites to !irtio=,# !irt"e"e notify re)ister 3EM:
+e"est header 6ata ,"ffer
6e!ice em"#ation
9"est
+e"est footer
9"est +*M
!m.o
'a%(throu$h irtio7b%( #i&( rea# re8ue&t 9art 2: 4. 3EM: iss"es ?- re"est on ,eha#f of )"est 3EM:
9"est
6e!ice em"#ation
6ata ,"ffer
$in"% *?VIS #oc #ayer ;hysica# dis
!m.o
'a%(throu$h irtio7b%( #i&( rea# re8ue&t 9art ;: 8. 3EM: fi##s in re"est footer and injects com#etion interr"t 3EM:
9"est
6e!ice em"#ation
+e"est footer
$in"% *?VIS #oc #ayer ;hysica# dis
?nterr"t !m.o
'a%(throu$h irtio7b%( #i&( rea# re8ue&t 9art <: 5. 9"est recei!es interr"t and e%ec"tes hand#er
'. 9"est reads data from ,"ffer
3EM: 9"est
+e"est header 6ata ,"ffer +e"est footer
?nterr"t !m.o
9"est +*M
han( you= echnica# disc"ssion/ em"=de!e#@non)n".or) ?+ ●
em" on irc.oftc.net
●
!m on chat.freenode.net
htt/em"=roject.or) htt/#in"%=!m.or) More on my ,#o)/ htt/,#o).!ms#ice.net