3 À<×e† ã@srddlmZddlZddlZddlZddlTddlZddl j Z ddl Tddl m Z ejjƒZGdd„dejƒZdS)é)ÚbaseéN)Ú*)ÚcommandscsfeZdZdZ‡fdd„Zdd„Zdd„Zdd „Zd d „Ze j fd d „Z dd„Z dd„Z dd„Z‡ZS)Ú SysfsPlugina| `sysfs`:: Sets various `sysfs` settings specified by the plug-in options. + The syntax is `_name_=_value_`, where `_name_` is the `sysfs` path to use and `_value_` is the value to write. The `sysfs` path supports the shell-style wildcard characters (see `man 7 glob` for additional detail). + Use this plugin in case you need to change some settings that are not covered by other plug-ins. Prefer specific plug-ins if they cover the required settings. + .Ignore corrected errors and associated scans that cause latency spikes ==== ---- [sysfs] /sys/devices/system/machinecheck/machinecheck*/ignore_ce=1 ---- ==== cs$tt|ƒj||Žd|_tƒ|_dS)NT)ÚsuperrÚ__init__Z_has_dynamic_optionsrÚ_cmd)ÚselfÚargsÚkwargs)Ú __class__©ú"/usr/lib/python3.6/plugin_sysfs.pyr'szSysfsPlugin.__init__cCs4d|_d|_tdd„t|jjƒƒDƒƒ|_i|_dS)NFTcSs$g|]}tjj|dƒ|df‘qS)rr)ÚosÚpathÚnormpath)Ú.0Ú key_valuerrrú 0sz.SysfsPlugin._instance_init..)Z_has_dynamic_tuningZ_has_static_tuningÚdictÚlistZoptionsÚitemsÚ_sysfsÚ_sysfs_original)r ÚinstancerrrÚ_instance_init,szSysfsPlugin._instance_initcCsdS)Nr)r rrrrÚ_instance_cleanup3szSysfsPlugin._instance_cleanupcCsvxpt|jjƒƒD]^\}}|jj|ƒ}xHtj|ƒD]:}|j|ƒr\|j|ƒ|j |<|j ||ƒq0t j d|ƒq0WqWdS)Nz)rejecting write to '%s' (not inside /sys)) rrrÚ _variablesÚexpandÚglobÚiglobÚ _check_sysfsÚ _read_sysfsrÚ _write_sysfsÚlogÚerror)r rÚkeyÚvalueÚvÚfrrrÚ_instance_apply_static6s  z"SysfsPlugin._instance_apply_staticc Cspd}xft|jjƒƒD]T\}}|jj|ƒ}x>tj|ƒD]0}|j|ƒr4|j|ƒ} |j ||| |ƒdkr4d}q4WqW|S)NTF) rrrrrr r!r"r#Z _verify_value) r rZignore_missingZdevicesÚretr'r(r)r*Zcurr_valrrrÚ_instance_verify_static@s    z#SysfsPlugin._instance_verify_staticcCs,x&t|jjƒƒD]\}}|j||ƒqWdS)N)rrrr$)r rZrollbackr'r(rrrÚ_instance_unapply_staticKsz$SysfsPlugin._instance_unapply_staticcCs tjd|ƒS)Nz^/sys/.*)ÚreÚmatch)r Ú sysfs_filerrrr"OszSysfsPlugin._check_sysfscCs2|jj|ƒjƒ}t|ƒdkr*|jj|dƒSdSdS)NrF)r Z read_fileÚstripÚlenZget_active_option)r r1Údatarrrr#Rs zSysfsPlugin._read_sysfscCs|jj||ƒS)N)r Z write_to_file)r r1r(rrrr$YszSysfsPlugin._write_sysfs)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrr+r-ÚconstsZ ROLLBACK_SOFTr.r"r#r$Ú __classcell__rr)r rr s   r)Úrr r/Zos.pathrZ decoratorsZ tuned.logsZtunedZ tuned.constsr9Ú subprocessZtuned.utils.commandsrZlogsÚgetr%ZPluginrrrrrÚs