资源描述:
《libvirt-hooks-network-hooks》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、Libvirthooks–networkhookshongming2014.6.41Hooking●Hookingcoversarangeoftechniquesusedtoalteroraugmentthebehaviorofanoperatingsystem,ofapplications,orofothersoftwarecomponentsbyinterceptingfunctioncallsormessagesoreventspassedbetweensoftwarecomponents●Codethathandlessuchint
2、erceptedfunctioncalls,eventsormessagesiscalleda"hook"customcode2LibvirthooksSpecificeventsonahostsystemwilltriggercustomscriptsThesecustomhookscriptsareexecutedwhenanyofthefollowingactionsoccur●Thelibvirtdaemonstarts,stops,orreloadsitsconfiguration●AQEMUguestisstartedorsto
3、pped,migrate,libvirtdrestart●AnLXCguestisstartedorstopped,libvirtdrestart●Anetworkisstartedorstoppedoraninterfaceisplugged/unpluggedto/fromthenetwork(newfeatureforrhel6.6)3Libvirthooks●Bug1064831-Haveupstreamnetworkhooksavailablein6.6It'dbegoodifrhel6.6includedthehookssoth
4、atRHEVcanrelyonthemforit'sQualityofServiceneeds./src/util/virnetdevbandwidth.cIf(bandwidth->in)If(bandwidth->out)RHVMVDSMhooks/usr/libexec/vdsm/hooks/nn_event-name/OpenStackNovahooks4Scriptlocation●/etc/libvirt/hooks/OtherLinuxdistributionsmaydothisdifferently.●Iftheinstal
5、lationoflibvirtiscompiledfromsource,itislikelytobe/usr/local/etc/libvirt/hooks/●Tousehookscripts,youwillneedtocreatethishooksdirectorymanually,placethedesiredhookscriptsinside,thenmakethemexecutable.5Scriptnames●Atpresent,therearefourhookscriptsthatcanbecalled:●/etc/libvir
6、t/hooks/daemon●/etc/libvirt/hooks/qemu●/etc/libvirt/hooks/lxc●/etc/libvirt/hooks/network6Scriptstructure●ThehookscriptsareexecutedusingstandardLinuxprocesscreationfunctions.Therefore,theymustbeginwiththedeclarationofthecommandinterpretertouse.●#!/bin/bash●#!/usr/bin/python
7、●Othercommandinterpretersareequallyvalid,asisanyexecutablebinary,soyouarewelcometouseyourfavouritelanguages.7ScriptargumentsThehookscriptsarecalledwithspecificcommandlinearguments,dependinguponthescript,andtheoperationbeingperformed.●Thefirstargumentisthenameoftheobjectinv
8、olvedintheoperation,or'-'ifthereisnone.(forexample:thenameofnetwork)●Thesecondargumentist