Tải bản đầy đủ - 0 (trang)
Chapter 13. Guest Save, Restore, and Live Migration

Chapter 13. Guest Save, Restore, and Live Migration

Tải bản đầy đủ - 0trang

stateofthemachinewhenmovingfromplacetoplace,orfor

conservingbatterypowerwhenthelaptopisnotbeingused.In

thecaseofavirtualmachinemonitorlikeXen,asimilarfacility

canbeusedtocheckpointstatestofacilitaterollbackinthe

eventaguestfails,ortosavethestateofaguestpastthe

shutdownofthephysicalmachineonwhichitisrunning.

Xenprovidesadomainsaveandrestorefacilitytohandlethe

suspensionofguestVMstocheckpointfiles,operatedbythexm

saveandxmrestorecommands.Whenaguestissavedto

diskitissuspended,anditsresourcesaredeallocated.Asinthe

caseofhibernate,ongoingnetworkconnectionsarenot

preserved.

Withthexmmigratecommand,Xensupportswarmstatic

migration(regularmigration),wherearunningguestis

temporarilysuspendedandthenrelocatedtoanotherphysical

host,aswellaslivemigration,whereaguestmayberelocated

fromonehosttoanotherseamlessly,withoutdroppingongoing

networkconnectionsandwithlittleclientperceptibledelay.Live

migrationisparticularlyusefulwhenbringingdownaphysical

machineformaintenance.Inthiscase,guestscanberelocated

toanewphysicalmachineinpreparationforthemaintenance

withoutadisruptioninservice.Theabilitytorelocateaguestis

alsousefulforloadbalancingguestsandtheirresource

consumption.

Inthischapter,wediscusstheusesofxmsave,xmrestore,

andxmmigrateindetail.



Chapter13.GuestSave,Restore,and

LiveMigration

Inthischapter,webeginbyexploringXen'scapabilitytoeasily

checkpointthestateofaguestdomaintodiskforquick

restorationatalatertime.WecontinuebyexploringhowXen

makesthemigrationofguestdomainsasimpleandpowerful

administrativetask.Wediscusscoldstaticmigration,warm

staticmigration,andlivemigrationofguests,alongwiththe

prerequisitesandbenefitsofeach.



RepresentingtheStateofaVirtual

Machine

Attheheartofanymigrationistheabilitytofullyrepresentthe

stateofaguest.Whenaguestvirtualmachineiscompletely

shutdown,thisistrivial.AninactiveXenguestiscompletely

definedbyitsfilesystemimage(s),configurationfile,andits

operatingsystemkernel.Clearly,aguestcouldbeclonedor

evenmovedtoanotherphysicalmachinebymakingcopiesof

thesefiles.Backupofaguestcanbeaccomplishedinthisway.

Aguestthatisactiveinexecution,ontheotherhand,isamore

complicatedmatter.Whileaguestisrunning,savingitsstate

additionallyinvolvescreatingasnapshotofitsmemory,device

I/Ostates,opennetworkconnections,andthecontentsofits

virtualCPUregisters.Xencansavethisstateinformationto

diskortransferitoverthenetwork,whichallowsforboth

backupandmigrationofVMs.

Thisideaofsavingthestateofarunningguestissimilartothe

hibernationfeatureonmanypersonalcomputers,whichis

especiallypopularamonglaptopusers.Inhibernation,a

system'sstateischeckpointedandsavedtodisksothatthe

systemcanparktheharddriveheads,powerdown,and

resumeitspreviousstatenexttimeitispoweredup.Laptop

userssometimesrelyonthisfeaturetotemporarilysuspendthe



stateofthemachinewhenmovingfromplacetoplace,orfor

conservingbatterypowerwhenthelaptopisnotbeingused.In

thecaseofavirtualmachinemonitorlikeXen,asimilarfacility

canbeusedtocheckpointstatestofacilitaterollbackinthe

eventaguestfails,ortosavethestateofaguestpastthe

shutdownofthephysicalmachineonwhichitisrunning.

Xenprovidesadomainsaveandrestorefacilitytohandlethe

suspensionofguestVMstocheckpointfiles,operatedbythexm

saveandxmrestorecommands.Whenaguestissavedto

diskitissuspended,anditsresourcesaredeallocated.Asinthe

caseofhibernate,ongoingnetworkconnectionsarenot

preserved.

Withthexmmigratecommand,Xensupportswarmstatic

migration(regularmigration),wherearunningguestis

temporarilysuspendedandthenrelocatedtoanotherphysical

host,aswellaslivemigration,whereaguestmayberelocated

fromonehosttoanotherseamlessly,withoutdroppingongoing

networkconnectionsandwithlittleclientperceptibledelay.Live

migrationisparticularlyusefulwhenbringingdownaphysical

machineformaintenance.Inthiscase,guestscanberelocated

toanewphysicalmachineinpreparationforthemaintenance

withoutadisruptioninservice.Theabilitytorelocateaguestis

alsousefulforloadbalancingguestsandtheirresource

consumption.

Inthischapter,wediscusstheusesofxmsave,xmrestore,

andxmmigrateindetail.



BasicGuestDomainSaveandRestore

Xenmakesitpossibletosuspendaguestdomain,saveitsstate

toafile,andresumethatstatelaterthroughitsdomainsave

andrestorefacility.Figure13.1illustratestheprocessofsaving

aguest'sstatetodisk.Aswithhibernation,whenadomain's

stateissavedondisk,itissuspended,andnetworkconnections

toandfromthatguestareinterrupted(duetoTCPtimeouts).

Figure13.1.Xenprovidesaneasy-to-usefacilityfor

hibernatinggueststocheckpointfiles,toberestoredata

laterpointintime.



xmsave

SavingaguestVM'sstatefirstsuspendsthatguestVMand

thendumpsitsstateinformationtodisk.TheguestVMwillnot

continuetoexecuteuntilitisrestored,muchlikeinthecaseof

hibernation.

Listing13.1showsthesyntaxofthiscommand.

Listing13.1.Usageofxmsave



xmsavedomainfilename



Whenperforminganxmsave,anadministratorsuppliesa

filenameargumenttospecifywheretheserializedstateofthe

guestVMshouldbewritten.Thisfileiscolloquiallycalleda

checkpointfile.Thisdoesnoteraseanypreviouslysaved

checkpoints.Youarefreetosaveasmanydistinctcheckpoints

asyouwant.Thusitispossibletoarchiveacollectionof

differentrunningstatesforaparticularguestdomain.

EitheraguestdomainIDnumberordomainnamemaybe

suppliedasthedomainargument.Afterrunningthiscommand,

Xensuspendsthestateoftheguest-specifieddomaintothe

specifiedfile,andthedomainnolongerexecutesonthehost.

ThusitisimpossibletosavethestateofDomain0inthis

fashionbecausetheXenDomain0mustremainoperationalas

thecontrolinterfacebetweentheadministratorandXen.

InListing13.2,weshowtheoutputofxmlistrunningin

Domain0.Theoutputshownillustrateswearerunningaguest

domainnamedTestGuestthathas64MBofRAMallocatedtoit.

Listing13.2.DomainsRunningonDomain0(Before

Checkpointing)



[root@dom0]#xmlist

NameIDMem(MiB)VCPUsStateTime(

Domain-005112r-----1306

TestGuest1631-b----4

[root@dom0]#



TosaveTestGuest'sstate,thecorrespondingIDnumberneeds

tobenotedandpassedasanargumenttothexmsave

command.InListing13.2weseethattheIDthatcorresponds



withTestGuestis1,andanexamplesuspensionusingthe

checkpointfilenameTestGuest.checkptisshowninListing

13.3.

Listing13.3.CheckpointingaGuest'sStateUsingxmsave

[root@dom0]#xmsave1TestGuest.checkpt

[root@dom0]#



Notethatreplacing1withTestGuestasanargumenttoxm

savealsoworks.WeknowthatthestateofTestGuesthas

successfullyfinishedsavingwhenitisnolongerlistedas

residingonDomain0,whichwecheckbyinvokingxmlistas

showninListing13.4.Thexmsavecommanddoesnotreturn

immediately,butinsteadreturnsaftercheckpointingis

complete.

Listing13.4.DomainsRunningonDomain0(After

Checkpointing)



[root@dom0]#xmlist

NameIDMem(MiB)VCPUsStateTime(

Domain-005112r-----1411

[root@dom0]#



Wecanobservethatourcheckpointfilenowexistsinthe

presentworkingdirectoryanddetermineitssizebyissuingthe

ls-lacommandasshowninListing13.5.Thels-lah

commandmayinsteadbeusedtoviewfilesizesthataremore

humanreadable.

Listing13.5.CheckpointFile



[root@dom0]#ls-la

-rwxr-xr-x1rootroot67266796Feb603:54TestGuest.checkpt

[root@dom0]#



NowthatTestGuesthasbeensuspended,isnolonger

executing,andhasbeensavedtoastatefile,wehave

successfullyusedXen'sdomainsavefacility.Notethatifthereis

notenoughdiskspacetosavethecheckpointfile,theguest

remainsrunningandthexmsavecommandfailswithageneric

errormessage.

Acheckpointcontainsthecontentsoftheentirememorystate

oftheguest.Thus,thetimerequiredtosavetheguest'sstate

isproportionaltotheamountofmemoryallocatedforthe

guest.Thesizeofthecheckpointfileisalsoapproximatelythe

sameastheamountofmemoryallocatedtotheguestVM,plus

asmallamountofextradiskspacetostoreadditionalstate

information.

Listing13.6showstheoutputofxmlistforasystemwith

threesampleguests—onewith64megabytes,onewith128

megabytes,andonewith256megabytesofRAMallocated.

Table13.1showsthesizeofthecheckpointfileandthetotal

timetakentosaveeachoftheseguests.Inallthreecases,the

checkpointfileisslightlylargerthantheamountofmemory

allocatedtotheguest.Itisalsoclearthatthetimetakento

completethesavegrowswiththeanincreaseinamountof

allocatedmemory.Theactualtimetakentosavetheguest's

statevarieswiththespeedoftheunderlyingfilesystemand

thehardwareusedtostorethecheckpointfile.

Table13.1.CheckpointFileSizeandTime

Proportions

ActualGuest

FileSize

TimetoSave

RAMAllocation OnDisk

GuestState

(MB)

(MB)

(sec)



65.5



67.1



0.859



130.8



134.5



2.426



261.9



268.7



4.802



Listing13.6.DomainsRunningonDomain0withVarying

MemoryAllocations



[root@dom0_Host1]#xmlist

NameIDMem(MiB)VCPUsStateTime(

Domain-005112r-----1306

Guest64MB7631-b----3

Guest128MB81271-b----2

Guest256MB92551-b----2

[root@dom0_Host1]#



xmrestore

Restoringaguestdomainfromastatefileisinitiatedbythexm

restorecommand.Listing13.7showsthesyntaxofthis

command.

Listing13.7.Usageofxmrestore

xmrestorefilename



Ontheexecutionofthiscommand,Xenrestoresthestateofthe

guestlocatedinthespecifiedfilename.Thenumericaldomain

IDofaguestdomainisnotpreservedthroughsaveand

restore,sonoconsiderationneedstobetakentoavoidanID

conflict—auniqueIDisautomaticallyassignedwhenrestoringa

guestfromacheckpointfile.



OnDomain0,wecurrentlyhaveastatefileforadomaininthe

presentworkingdirectory,observedbyissuingthels

command,asshowninListing13.8.

Listing13.8.CheckpointFile

[root@dom0]#ls

TestGuest.checkpt

[root@dom0]#



NotethatnoguestdomainsarecurrentlyresidingonDomain0,

byinvokingxmlist,aswedoinListing13.9.

Listing13.9.DomainsRunningonDomain0(Before

Restoration)



[root@dom0]#xmlist

NameIDMem(MiB)VCPUsStateTime(

Domain-005112r-----1702

[root@dom0]#



Torestorethedomainfromourcheckpointfile,weissuethexm

restorecommandwithitscheckpoint'sfilenameasan

argument,asinListing13.10.

Listing13.10.RestoringaGuest'sStateUsingxmrestore

[root@dom0]#xmrestoreTestGuest.checkpt

[root@dom0]#



Weknowthatrestorationiscompletewhenwecanobserve



TestGuestresidingonDomain0,byinvokingxmlist,shownin

Listing13.11.Thexmrestorecommandwillnotreturnuntil

restorationiscomplete.OnceTestGuestisrestoredfromastate

file,itcontinuesexecutingwhereitleftoffatthetimeitwas

suspended,thoughnetworkconnectionsarelikelytohave

timedout.

Listing13.11.DomainsRunningonDomain0(After

Restoration)



[root@dom0]#xmlist

NameIDMem(MiB)VCPUsStateTime(

Domain-005112r-----1795

TestGuest2631-b----0

[root@dom0]#



Xen'sdomainsaveandrestorefacilityhasseveralpotential

uses.Forexample,theabilitytorestorefromcheckpointsmay

potentiallybeusedindevelopingarapidcrashrecovery

procedure,whereaguestisrestoredtoadefaultstatemuch

fasterthanrebooting.Similarly,itisalsousefulwhiledebugging

ortestingchangestoasystem,byallowinganadministratorto

savequicklyrestorablecheckpointsthatcanberevertedtoin

theeventofafailure.Quickinstallscannotbeperformedsimply

byprovidingsuchanimagebecausecheckpointfilesdonot

containaguest'sfilesystemcontents;instead,quickinstalls

andzerosetupinstallationswouldrequireanimageofaguest's

filesystem,andoptionallyacheckpointfile,ifitisdesiredto

shiptheinstallationwiththeguestbeinginaparticular

executionstate.



PossibleSaveandRestoreErrors

Listing13.12showstheerrorthatoccurswhenthereisnot

enoughdiskspacetostorethecheckpointfileofaguestatthe

locationofthepathspecifiedbytheuser.Youshouldfreeup



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Chapter 13. Guest Save, Restore, and Live Migration

Tải bản đầy đủ ngay(0 tr)

×