您的位置:首页 > 其它

QEMU KVM libvirt手册(2): monitor

2014-11-04 18:42 302 查看


AdministratingVirtualMachineswithQEMUMonitor

WhenQEMUisrunning,amonitorconsoleisprovidedforperforminginteractionwiththeuser.Usingthecommandsavailableinthemonitorconsole,itispossibletoinspecttherunningoperatingsystem,changeremovablemedia,takescreenshotsoraudiograbs
andcontrolseveralotheraspectsofthevirtualmachine.


AccessingMonitorConsole

ToaccessthemonitorconsolefromQEMU,pressCtrl+Alt+2.ToreturnbacktoQEMUfromthemonitorconsole,pressCtrl+Alt+1.

Togethelpwhileusingtheconsole,usehelpor?.Togethelpforaspecificcommand,usehelpcommand.




GettingInformationabouttheGuestSystem

Togetinformationabouttheguestsystem,usetheinfooptioncommand.Ifusedwithoutanyoption,thelistofpossibleoptionsisprinted.Optionsdeterminewhichpartofthesystemwillbeanalyzed:

infoversion
ShowstheversionofQEMU
infocommands
ListsavailableQMPcommands
infonetwork

Showsthenetworkstate
infochardev

Showsthecharacterdevices
infoblock

Informationaboutblockdevices,suchasharddrives,floppydrives,orCD-ROMs



infoblockstatsReadandwritestatisticsonblockdevices

inforegistersShowstheCPUregisters

infocpusShowsinformationaboutavailableCPUs

infohistoryShowsthecommandlinehistory

infoirqShowstheinterruptsstatistics

infopicShowsthei8259(PIC)state

infopciShowsthePCIinformation

infotlbShowsvirtualtophysicalmemorymappings

infomemShowstheactivevirtualmemorymappings

infojitShowsdynamiccompilerinformation

infokvmShowstheKVMinformation

infonumaShowstheNUMAinformation

infousbShowstheguestUSBdevices

infousbhostShowsthehostUSBdevices

infoprofileShowstheprofilinginformation

infocaptureShowsthecapture(audiograb)information

infosnapshotsShowsthecurrentlysavedvirtualmachinesnapshots

infostatusShowsthecurrentvirtualmachinestatus

infopcmciaShowstheguestPCMCIAstatus

infomiceShowswhichguestmiceisreceivingevents

infovncShowstheVNCserverstatus

infonameShowsthecurrentvirtualmachinename

infouuidShowsthecurrentvirtualmachineUUID

infousernetShowstheusernetworkstackconnectionstates

infomigrateShowsthemigrationstatus

infoballoonShowstheballoondeviceinformation

infoqtreeShowsthedevicetree

infoqdmShowstheqdevdevicemodellist

inforomsShowstheROMs

infomigrate_cache_sizesShowsthecurrentmigrationxbzrle(=XorBasedZeroRunLengthEncoding)cachesize.

infomigrate_capabilitiesShowsthestatusofthevariousmigrationcapabilities,suchasxbzrlecompression.

infomtreeShowstheVMGuestmemoryhierarchy.

infotrace-events

Showsavailabletrace-eventsandtheirstatus.



这些都可以在VNCViewer里面运行,然而有时候屏幕太小,不全,可以使用virsh进行操作

virsh#list

IdNameState

----------------------------------------------------

14instance-00000009running

15instance-0000000arunning

virsh#qemu-monitor-command14--hmp"infokvm"

kvmsupport:enabled

virsh#qemu-monitor-command14--hmp"infoblockstats"

drive-virtio-disk0:rd_bytes=274441728wr_bytes=777724928rd_operations=15528wr_operations=6520flush_operations=673wr_total_time_ns=121355399653rd_total_time_ns=18996983203flush_total_time_ns=4363807221

virsh#qemu-monitor-command14--hmp"inforegisters"

RAX=0000000000000000RBX=ffffffff81c01fd8RCX=00000000ffffffffRDX=0000000000000000

RSI=0000000000000001RDI=ffffffff81ddae48RBP=ffffffff81c01ea8RSP=ffffffff81c01ea8

R8=0000000000000000R9=0000000000000000R10=0000000000000000R11=0000000000000001

R12=ffffffff81cdc7c0R13=0000000000000000R14=ffffffffffffffffR15=000000000008c800

RIP=ffffffff8103df56RFL=00000246[---Z-P-]CPL=0II=0A20=1SMM=0HLT=1

ES=00000000000000000000000fffff00000000

CS=00100000000000000000ffffffff00a09b00DPL=0CS64[-RA]

SS=00180000000000000000ffffffff00c09300DPL=0DS[-WA]

DS=00000000000000000000000fffff00000000

FS=00000000000000000000ffffffff00000000

GS=0000ffff88007fc00000000fffff00000000

LDT=00000000000000000000000fffff00000000

TR=0040ffff88007fc112c00000208700008b00DPL=0TSS64-busy

GDT=ffff88007fc040000000007f

IDT=ffffffff81dd700000000fff

CR0=8005003bCR2=00007fff4cf57000CR3=000000007b7fa000CR4=001406f0

DR0=0000000000000000DR1=0000000000000000DR2=0000000000000000DR3=0000000000000000

DR6=00000000ffff0ff0DR7=0000000000000400

EFER=0000000000000d01

FCW=037fFSW=0000[ST=0]FTW=00MXCSR=00001f80

FPR0=00000000000000000000FPR1=00000000000000000000

FPR2=00000000000000000000FPR3=00000000000000000000

FPR4=00000000000000000000FPR5=00000000000000000000

FPR6=00000000000000000000FPR7=00000000000000000000

XMM00=ffffffff00000000ffffffffff000000XMM01=00000000000000000000000000ffffff

XMM02=00000000000000000000000000435455XMM03=000000ff000000000000000000ff0000

XMM04=40404040404040404040404040404040XMM05=5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a

XMM06=20202020202020202020202020202020XMM07=ffff00ffffff00ffffffff00ffffffff

XMM08=00200000002000000000000000000000XMM09=ff00ff00000000000000000000000000

XMM10=00002000000000000000000000000000XMM11=00000000000000000000000000000000

XMM12=00000000000000000000000000000000XMM13=00000000000000000000000000000000

XMM14=00000000000000000000000000000000XMM15=00000000000000000000000000000000

virsh#qemu-monitor-command14--hmp"infotlb"

0000000000400000:0000000075a3f000----A--U-

0000000000401000:0000000075a3e000----A--U-

0000000000402000:00000000759ff000----A--U-

0000000000403000:00000000759fe000----A--U-

0000000000404000:0000000074dfe000----A--U-

0000000000405000:0000000074dbf000----A--U-

0000000000406000:0000000074dbe000----A--U-

0000000000407000:0000000074d7f000----A--U-

0000000000408000:0000000074dff000----A--U-

0000000000409000:0000000074e3e000----A--U-

000000000040a000:0000000074e3f000----A--U-

000000000040b000:0000000074e7e000----A--U-

000000000040c000:0000000074e7f000----A--U-

000000000040d000:0000000074ebe000----A--U-

000000000040e000:0000000074ebf000----A--U-

virsh#qemu-monitor-command14--hmp"infomem"

0000000000400000-00000000004200000000000000020000ur-

0000000000421000-00000000004260000000000000005000ur-

0000000000427000-000000000042c0000000000000005000ur-

000000000042e000-000000000044c000000000000001e000ur-

0000000000656000-00000000006580000000000000002000ur-

0000000000658000-000000000065b0000000000000003000urw

000000000065b000-000000000065d0000000000000002000ur-

000000000065d000-000000000065f0000000000000002000urw

00000000006e1000-00000000006e30000000000000002000urw

00000000006e3000-00000000006e50000000000000002000ur-

00000000006e5000-00000000006e80000000000000003000urw

00000000006e8000-00000000006e90000000000000001000ur-

00000000006e9000-00000000006ea0000000000000001000urw

00000000006ea000-00000000006eb0000000000000001000ur-

00000000006eb000-00000000007010000000000000016000urw

0000000000712000-00000000007150000000000000003000urw

00007f0a00000000-00007f0a0003c000000000000003c000urw

00007f0a04000000-00007f0a040040000000000000004000urw

00007f0a08000000-00007f0a080020000000000000002000urw

00007f0a0e8ea000-00007f0a0e8ec0000000000000002000urw

00007f0a0f0e2000-00007f0a0f0e30000000000000001000urw

00007f0a0f0ea000-00007f0a0f0ed0000000000000003000urw

00007f0a0f8ea000-00007f0a0f8ee0000000000000004000urw

00007f0a0f8ee000-00007f0a0f8f10000000000000003000ur-

virsh#qemu-monitor-command14--hmp"infoballoon"

balloon:actual=2048


ChangingVNCPassword

TochangetheVNCpassword,usethechangevncpasswordcommandandenterthenewpassword:
(qemu)changevncpassword
Password:********
(qemu)




ManagingDevices

Toreleasethedeviceorfileconnectedtotheremovablemediadevice,usetheejectdevicecommand.Usetheoptional-ftoforceejection.

Tochangeremovablemedia(likeCD-ROMs),usethechangedevicecommand.Thenameoftheremovablemediacanbedeterminedusingtheinfoblockcommand:
(qemu)infoblock
ide1-cd0:type=cdromremovable=1locked=0file=/dev/sr0ro=1drv=host_device
(qemu)changeide1-cd0/path/to/image


ChangingAvailableMemory

Ifthevirtualmachinewasstartedwiththe-balloonvirtiooptionandtheparavirtualizedballoondevicethatallowstodynamicallychangetheamountofmemoryavailableisthereforeenabled,itispossibletochangetheavailablememorydynamically.Formore
informationaboutenablingtheballoondevice.

Togetinformationabouttheballoondeviceinthemonitorconsoleandtodeterminewhetherthedeviceisenabled,usetheinfoballooncommand:
(qemu)infoballoon


Iftheballoondeviceisenabled,usetheballoonmemory_in_MBcommandtosettherequestedamountofmemory:
(qemu)balloon400


virsh#qemu-monitor-command14--hmp"infoballoon"

balloon:actual=2048


DumpingVirtualMachineMemory

Tosavethecontentofthevirtualmachinememorytoadiskorconsoleoutput,usethefollowingcommands:

memsaveaddrsizefilename
Savesvirtualmemorydumpstartingataddrofsizesizetofilefilename
pmemsaveaddrsizefilename

Savesphysicalmemorydumpstartingataddrofsizesizetofilefilename

filename保存在HOST机器上

addr最小是0000000000400000


ManagingVirtualMachineSnapshots

VirtualmachinesnapshotsaresnapshotsofthecompletevirtualmachineincludingthestateofCPU,RAM,andthecontentofallwritabledisks.Tousevirtualmachinesnapshots,youmusthaveatleastonenon-removableandwritableblockdeviceusingtheqcow2
diskimageformat.

ThefollowingcommandsareavailableformanagingsnapshotsinQEMUmonitor:

savevmname
Createsanewvirtualmachinesnapshotunderthetagnameorreplacesanexistingsnapshot.
loadvmname

Loadsavirtualmachinesnapshottaggedname.
delvm

Deletesavirtualmachinesnapshot.
infosnapshots

Printsinformationaboutavailablesnapshots.
(qemu)infosnapshots
Snapshotlist:
IDTAGVMSIZEDATEVMCLOCK
1booting4.4M2010-11-2210:51:1000:00:20.476
2booted184M2010-11-2210:53:0300:02:05.394
3logged_in273M2010-11-2211:00:2500:04:34.843
4ff_and_term_running372M2010-11-2211:12:2700:08:44.965

Uniqueidentificationnumberofthesnapshot.Usuallyauto-incremented.
Uniquedescriptionstringofthesnapshot.ItismeantasahumanreadableversionoftheID.
Thediskspaceoccupiedbythesnapshot.Notethatthemorememoryisconsumedbyrunningapplications,thebiggerthesnapshotis.
Timeanddatethesnapshotwascreated.
Thecurrentstateofthevirtualmachine'sclock.




SuspendingandResumingVirtualMachineExecution

Thefollowingcommandsareavailableforsuspendingandresumingvirtualmachines:

stop
Suspendstheexecutionofthevirtualmachine.
cont

Resumestheexecutionofthevirtualmachine.
system_powerdown

SendsanACPIshutdownrequesttothemachine.Theeffectissimilartothepowerbuttononaphysicalmachine.
qorquit

TerminatesQEMUimmediately.


LiveMigration

Thelivemigrationprocessallowstotransmitanyvirtualmachinefromonehostsystemtoanotherhostsystemwithoutanyinterruptioninavailability.Itispossibletochangehostspermanentlyorjustduringamaintenance.Itisrecommendedthatthesource
anddestinationsystemshavethesamearchitecture,howeveritispossibletomigratebetweenhostswithAMDandIntelarchitectures.

Therequirementsforthelivemigration:

LivemigrationisonlypossiblebetweenVMHostServerswiththesameCPUfeatures.TheonlysupportedCPUmodelformigrationis-cpuqemu64(default)withnoadditionalfeaturesspecified.

Nophysicaldevicescanbepassedfromhosttoguest.

TheVMHostServerandVMGuestneedtohavepropertimekeepinginstalled.

AHCIinterface,virtfsfeature,andthe-mem-pathcommand-lineoptionarenotcompatiblewithmigration.

MigrationfromSP3toSP2orSP1hostedguestsisnotsupported.

Thevirtualmachineimagemustbeaccessibleonbothsourceanddestinationhosts.Forexample,itcanbelocatedonasharedNFSdisk.

Theimagedirectoryshouldbelocatedinthesamepathonbothhosts.

Bothhostsmustbelocatedinthesamesubnet.

Theguestonthesourceanddestinationhostsmustbestartedinthesameway.

Thelivemigrationprocesshasthefollowingsteps:

Thevirtualmachineinstanceisrunningonthesourcehost.

Thevirtualmachineisstartedonthedestinationhostinthefrozenlisteningmode.Theparametersusedarethesameasonthesourcehostplusthe-incomingtcp:ip:portparameter,whereipspecifies
theIPaddressandportspecifiestheportforlisteningtotheincomingmigration.If0issetasIPaddress,thevirtualmachinelistensonallinterfaces.

Onthesourcehost,switchtothemonitorconsoleandusethemigrate-dtcp:destination_ip:portcommandtoinitiatethemigration.

Todeterminethestateofthemigration,usetheinfomigratecommandinthemonitorconsoleonthesourcehost.

Tocancelthemigration,usethemigrate_cancelcommandinthemonitorconsoleonthesourcehost.

Tosetthemaximumtolerabledowntimeformigrationinseconds,usethemigrate_set_downtimenumber_of_secondscommand.

Tosetthemaximumspeedformigrationinbytespersecond,usethemigrate_set_speedbytes_per_secondcommand.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: