+
     Gi7  c                   s    ^ RI t ^ RIt^RIHt ^RI5 ^ RIt^ RI5 ^ RI	H
t
 ^ RIHt ]P                  P                  4       t ! R R]P                   4      tR# )    N)base)Z*)commandsc                   s   a a ] tR t^t oRtV 3R ltR tR tR tR t	R t
R t]P                  3R	 ltR
 tRtVtV ;t# )ModulesPlugina  
Plug-in for applying custom kernel modules options.

This plug-in can set parameters to kernel modules. It creates
`/etc/modprobe.d/tuned.conf` file. The syntax is
`_module_=_option1=value1 option2=value2..._` where `_module_` is
the module name and `_optionx=valuex_` are module options which may
or may not be present.

.Load module `netrom` with module parameter `nr_ndevs=2`
====
----
[modules]
netrom=nr_ndevs=2
----
====

Modules can also be forced to load/reload by using an additional
`+r` option prefix.

.(Re)load module `netrom` with module parameter `nr_ndevs=2`
====
----
[modules]
netrom=+r nr_ndevs=2
----
====

The `+r` switch will also cause *TuneD* to try and remove `netrom`
module (if loaded) and try and (re)insert it with the specified
parameters. The `+r` can be followed by an optional comma (`+r,`)
for better readability.

When using `+r` the module will be loaded immediately by the *TuneD*
daemon itself rather than waiting for the OS to load it with the
specified parameters.
c                s\   < \         \        V `
  ! V/ VB  R V n        \	        4       V n        R# )TN)Zsuperr   __init___has_dynamic_optionsr   _cmd)selfZargsZkwargs	__class__s   &*,A/usr/lib/python3.14/site-packages/tuned/plugins/plugin_modules.pyr   ZModulesPlugin.__init__3   s(    t%t6v6"$j$)    c                sD    R Vn         RVn        VP                  Vn        R# )FTN)Z_has_dynamic_tuningZ_has_static_tuningZoptions_modulesr   instance   &&r	   _instance_initZModulesPlugin._instance_init8   s     !&( $(&&(r
   c                s    R # N r   r   r	   _instance_cleanupZModulesPlugin._instance_cleanup=   s    r
   c                s   V F  pV P                   P                  R RV.4      w  r4V^ 8  d   \        P                  R4        R# V^ 8  d,   \        P	                  RV: RVP                  4       : 24       V P                   P                  R V.4      w  r4V^ 8w  g   K  \        P                  RV: RVP                  4       : 24       K  	  R# )Zmodprobez-rzN'modprobe' command not found, cannot reload kernel modules, reboot is requiredNzcannot remove kernel module '': zcannot insert/reinsert module 'z', reboot is required: )r   executelogwarningdebugZstrip)r   Zmodulesmoduleretcodeouts   &&   r	   _reload_modulesZModulesPlugin._reload_modules@   s    f))##Zv$>?<7kKK`a
!II		LM))##Z$89<7lKKPVX[XaXaXcde r
   c                sD   V P                  4        R p^ pRp. p\        VP                  P                  4       4       EFQ  w  rgV P                  P                  V4      pV P                  P                  V4      p	V'       gb   V P                  P                  RV.4      w  r:V^ 8  d   Rp\        P                  R4       M#V^ 8  d   \        P                  RV,          4       V'       g
   V^ 8X  g   K  \        V	4      ^8  d8   V	R,          R8X  d*   \        P                  ! RR V	4      p	VP                  V4       \        V	4      ^ 8  d)   VR	V,           R
,           V	,           R,           ,          pEK5  \        P                  RV,          4       EKT  	  V P                  P!                  \"        P$                  V4       \        V4      pV^ 8  dS   V P'                  V4       \        VP                  4      V8w  d&   \        P)                  \"        P*                  4       R# R# R# ) FZmodinfoTz8'modinfo' command not found, not checking kernel modulesz)kernel module '%s' not found, skipping it:r    i   Nz+r^\s*\+r\s*,?\s*zoptions Z 
zKmodule '%s' doesn't have any option specified, not writing it to modprobe.dN)_clear_modprobe_filelistr   items
_variablesexpandr   r   r   r   errorlenresubZappendr   write_to_fileconstsMODULES_FILEr   infoZSTR_HINT_REBOOT)r   r   sr   Z
skip_checkZreload_listoptionvaluer   vr   ls   &&          r	   _instance_apply_staticZ$ModulesPlugin._instance_apply_staticL   s   !'*+H--3356mfOO""6*6e$1
99$$i%89LG{Z[[KL	1YY:VCDGqL
1vzafn	"B	*Q
1vz*v

#a
'$
..QYY\_eef# 7$ ))&--q1	+!U$	(

!HHV##$ " r
   c                s8    \        V4      P                  R R4      # )Z/r   )ZstrZreplace)r   pathr   r	   _unquote_pathZModulesPlugin._unquote_pathk   s    	T		3	##r
   c                s   R pR p\         P                  ! R4      p\        VP                  P	                  4       4       EF  w  rgV P
                  P                  V4      pV P
                  P                  V4      p	\         P                  ! RRV	4      p	RV,          p
\        P                  P                  V
4      '       g6   Rp\        P                  \        P                  R,          V,          4       K  \        P                  \        P                   R,          V,          4       VP#                  V	4      pV F  pVP#                  R^4      p\%        V4      ^8w  d    \        P'                  R	V: R
V: 24       KD  V P)                  V^ ,          V^,          V P*                  P-                  V
R,           V P/                  V^ ,          4      ,           RR R7      V4      R8X  g   K  RpK  	  EK  	  V# )Tz\s+r   r   z/sys/module/%sFzmodule '%s' is not loadedzmodule '%s' is loadedZ=z'unrecognized module option for module 'r   z/parameters/N)Zerr_retno_error)r&   compiler    r   r!   r"   r#   r'   osr2   Zexistsr   r$   r)   ZSTR_VERIFY_PROFILE_FAILr+   ZSTR_VERIFY_PROFILE_OKsplitr%   r   Z_verify_valuer   	read_filer3   )r   r   Zignore_missingZdevicesZretrr-   r.   r   r/   Zmpathr0   ZitemZargs   &&&&          r	   _instance_verify_staticZ%ModulesPlugin._instance_verify_staticn   s{   #.jj!H--3356mfOO""6*6e$1	vv "a(1f$5
''..


CIIf,,/JJVSTHHV)),CCfLM	
A::c1SCA	kkfdST			CFCFyy5>1D4F4Fs1v4NNZ^kop

    7( 
*r
   c                sT    V\         P                  8X  d   V P                  4        R # R # r   )r)   ZROLLBACK_FULLr   )r   r   Zrollbacks   &&&r	   _instance_unapply_staticZ&ModulesPlugin._instance_unapply_static   s!    %%% &r
   c                s   V P                   P                  \        P                  R R7      pVP	                  R4      p^ ;r4\        V4      p\        P                  ! R4      pW58  d)   VP                  W#,          4      f   TpTpV^,          pK.  RP                  V^ V 4      p\        V4      ^ 8  d
   VR,          pV P                   P                  \        P                  V4       R# )T)r4   r   z^\s*#N)r   r8   r)   r*   r7   r%   r&   r5   ZsearchZjoinr(   )r   r,   r0   ZiZjZllr9   s   &      r	   r   Z"ModulesPlugin._clear_modprobe_file   s    
ii&--$?!ggdm!
)!
1v"jj!	hhqtn	A
A61
ii!A!VaZ91))&--q1r
   )r   r   )Z__name__Z
__module__Z__qualname__Z__firstlineno__Z__doc__r   r   r   r   r1   r3   r:   r)   ZROLLBACK_SOFTr;   r   Z__static_attributes__Z__classdictcell__Z__classcell__)r   Z__classdict__s   @@r	   r   r      sJ     $L
'

f%>$6 :@9M9M 2 2r
   r   )r&   Zos.pathr6   r   r   Z
decoratorsZ
tuned.logsZtunedZ
subprocessZtuned.utils.commandsr   Ztuned.constsr)   ZlogsZgetr   ZPluginr   r   r
   r	   <module>r<      s?    	      ) jjnnO2DKK O2r
   