ó æ ”\c@sýddlmZmZmZmZmZmZmZddlm Z ddl Zddl m Z ddl m Z ddlZddlZddlZddlZddlZddljZddlmZejjƒZdgZdefd „ƒYZdS( iÿÿÿÿ(tstoragetunitstmonitorstpluginstprofilestexportsthardware(tTunedExceptionNi(t controller(tdaemon(t GlobalConfigt ApplicationcBs’eZd d d„Zd„Zd„Zd„Zd„Zej d„Z d„Z d„Z ej d„Z ed „ƒZed „ƒZd „ZRS( c Csäd|_tjƒ}tj|ƒ}|dkr9tƒn||_|jjtj ƒrgt j dƒn t j dƒt j ƒ}|jjdtjƒ}tjd|ƒ}tjƒ}tjƒ} tjjƒ} tjjƒ|_tj ||||| | |j|jƒ} t|jjtjtjƒƒ} tj| || |ƒ} tjƒ}tjƒ}tj tj!ƒ}tj"||||j|jƒ}t#j$| |||j|ƒ|_%t&j'|j%|jƒ|_(|j)ƒd|_*dS(Ns8dynamic tuning is enabled (can be overridden in plugins)s#dynamic tuning is globally disabledtudev_buffer_sizet buffer_size(+tNonet_dbus_exporterRtPickleProvidertFactoryR tconfigtget_booltconststCFG_DYNAMIC_TUNINGtlogtinfoRt Repositorytget_sizetCFG_DEF_UDEV_BUFFER_SIZERt Inventoryt DeviceMatchertDeviceMatcherUdevRtinstanceRt variablest VariablestinttgettCFG_DEFAULT_INSTANCE_PRIORITYt!CFG_DEF_DEFAULT_INSTANCE_PRIORITYRtManagertMergertLocatortLOAD_DIRECTORIEStLoaderR tDaemont_daemonRt Controllert _controllert _init_signalst _pid_file(tselft profile_nameRtstorage_providertstorage_factorytmonitors_repositoryR thardware_inventorytdevice_matchertdevice_matcher_udevtplugin_instance_factorytplugins_repositorytdef_instance_priorityt unit_managertprofile_factorytprofile_mergertprofile_locatortprofile_loader((s</usr/lib/python2.7/site-packages/tuned/daemon/application.pyt__init__s8      !   !! cs&‡‡fd†}tjˆ|ƒdS(Ncsˆ|krˆƒndS(N((t_signal_numbert_frame(thandlert signal_number(s</usr/lib/python2.7/site-packages/tuned/daemon/application.pythandler_wrapper;s (tsignal(R0RDRCRE((RCRDs</usr/lib/python2.7/site-packages/tuned/daemon/application.pyt_handle_signal:scCsO|jtj|jjƒ|jtj|jjƒ|jtj|jjƒdS(N(RGRFtSIGHUPR-treloadtSIGINTt terminatetSIGTERM(R0((s</usr/lib/python2.7/site-packages/tuned/daemon/application.pyR.@scCs]|jdk rtdƒ‚ntjj|||ƒ|_tj|jƒtj|jƒdS(Ns&DBus interface is already initialized.( RRRRtdbust DBusExportertregister_exportertregister_objectR-(R0tbus_namet object_nametinterface_name((s</usr/lib/python2.7/site-packages/tuned/daemon/application.pytattach_to_dbusEs cCsþtj|ƒtj|gggtjƒ\}}}t|ƒdkrbtj|ƒtdƒ‚ntj|dƒ}tj|ƒt|ƒdkr¢tdƒ‚nytj d|ƒd}Wn tj k rÞtdƒ‚nX|t krútdƒ‚nd S( s| Wait till the child signalizes that the initialization is complete by writing some uninteresting data into the pipe. is=Cannot daemonize, timeout when waiting for the child process.iis:Cannot daemonize, no response from child process received.t?s?Cannot daemonize, invalid response from child process received.s0Cannot daemonize, child process reports failure.N( tostclosetselectRtDAEMONIZE_PARENT_TIMEOUTtlenRtreadtstructtunpackterrortTrue(R0t parent_in_fdt child_out_fdt read_readytdroptresponsetval((s</usr/lib/python2.7/site-packages/tuned/daemon/application.pyt_daemonize_parentMs '   cCsã||_|jƒytjj|jƒ}tjj|ƒsMtj|ƒntjtj|jtj tj Btj Bdƒdƒ}|j dtj ƒƒWdQXWn9ttfk rÞ}tjd|jt|ƒfƒnXdS(Ni¤tws%dscannot write the PID to %s: %s(R/t_delete_pid_fileRVtpathtdirnametexiststmakedirstfdopentopentO_CREATtO_TRUNCtO_WRONLYtwritetgetpidtOSErrortIOErrorRtcriticaltstr(R0tpid_filetdir_nametfR^((s</usr/lib/python2.7/site-packages/tuned/daemon/application.pytwrite_pid_filefs  8!cCsftjj|jƒrbytj|jƒWqbtk r^}tjd|jt|ƒfƒqbXndS(Ns&cannot remove existing PID file %s, %s( RVRiRkR/tunlinkRtRtwarningRw(R0R^((s</usr/lib/python2.7/site-packages/tuned/daemon/application.pyRhss cCs~tj|ƒtjdƒtjƒtjdƒy,tjƒ}|dkr\tjdƒnWnetk rÄ}t j dt |ƒƒt j dtƒ}tj||ƒtj|ƒtdƒ‚nXtddƒ}tj|jƒtjjƒƒtj|jƒtjjƒƒtj|jƒtjjƒƒ|j|ƒt jdƒt j dtƒ}tj||ƒtj|ƒd S( sy Finishes daemonizing process, writes a PID file and signalizes to the parent that the initialization is complete. t/is"cannot daemonize, fork() error: %sRUs'Cannot daemonize, second fork() failed.s /dev/nullsw+ssuccessfully daemonizedN(RVRWtchdirtsetsidtumasktforktsystexitRtRRvRwR\tpacktFalseRrRRntdup2tfilenotstdintstdouttstderrR{tdebugR_(R0RxR`RatpidR^Retfd((s</usr/lib/python2.7/site-packages/tuned/daemon/application.pyt_daemonize_childzs.         cCsÊtjƒ}ytjƒ}WnAtk r_}tj|dƒtj|dƒtdƒ‚nXy=|dkrŒ|j|Œtjdƒn|j ||ŒWn&|dkrµ‚qÆtjdƒnXdS(sÚ Daemonizes the application. In case of failure, TunedException is raised in the parent process. If the operation is successfull, the main process is terminated and only child process returns from this method. iis Cannot daemonize, fork() failed.N( RVtpipeR‚RtRWRRfRƒR„R(R0Rxtparent_child_fdst child_pidR^((s</usr/lib/python2.7/site-packages/tuned/daemon/application.pyt daemonizeœs     cCs|jS(N(R+(R0((s</usr/lib/python2.7/site-packages/tuned/daemon/application.pyR ·scCs|jS(N(R-(R0((s</usr/lib/python2.7/site-packages/tuned/daemon/application.pyR»scCs¡|r|jjtjtƒn|jjtjtjƒsJtjdƒn|j j ƒ}|jjtjtjƒrt j ƒn|j dk r|jƒn|S(NsrUsing one shot no deamon mode, most of the functionality will be not available, it can be changed in global config(RtsetRt CFG_DAEMONR_RtCFG_DEF_DAEMONRtwarnR-trunRtstopR/RRh(R0R tresult((s</usr/lib/python2.7/site-packages/tuned/daemon/application.pyR˜¿s  N(t__name__t __module__RR@RGR.RTRfRtPID_FILER{RhRR“tpropertyR RR˜(((s</usr/lib/python2.7/site-packages/tuned/daemon/application.pyR s'      "(ttunedRRRRRRRttuned.exceptionsRt tuned.logstRR RFRVRƒRXR\t tuned.constsRttuned.utils.global_configR tlogsR"Rt__all__tobjectR (((s</usr/lib/python2.7/site-packages/tuned/daemon/application.pyts4