MOON
Server: Apache
System: Linux s5.yayogua.com.py 6.12.0-124.55.3.el10_1.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:54:02 EDT 2026 x86_64
User: sanbercountryclu (1012)
PHP: 8.2.33
Disabled: NONE
Upload Files
File: //lib/python3.12/site-packages/tuned/plugins/__pycache__/plugin_modules.cpython-312.opt-1.pyc
�

�]�i7���ddlZddlZddlmZddl�ddlZddl�ddl	m
Z
ddlmZejj�ZGd�dej �Zy)�N�)�base)�*)�commandsc�j��eZdZdZ�fd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
ejfd	�Z
d
�Z�xZS)�
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�X��tt|�
|i|��d|_t	�|_y)NT)�superr�__init__�_has_dynamic_optionsr�_cmd)�self�args�kwargs�	__class__s   ��A/usr/lib/python3.12/site-packages/tuned/plugins/plugin_modules.pyrzModulesPlugin.__init__3s(����
�t�%�t�6�v�6�"�$���j�$�)�c�B�d|_d|_|j|_y)NFT)�_has_dynamic_tuning�_has_static_tuning�options�_modules�r�instances  r�_instance_initzModulesPlugin._instance_init8s ��!&�(�� $�(���&�&�(�rc��y�N�rs  r�_instance_cleanupzModulesPlugin._instance_cleanup=s��rc��|D]�}|jjdd|g�\}}|dkrtjd�y|dkDr)tj	d|�d|j����|jjd|g�\}}|dk7s��tjd|�d|j������y)	N�modprobez-rrzN'modprobe' command not found, cannot reload kernel modules, reboot is requiredzcannot remove kernel module '�': zcannot insert/reinsert module 'z', reboot is required: )r
�execute�log�warning�debug�strip)r�modules�module�retcode�outs     r�_reload_moduleszModulesPlugin._reload_modules@s����f��)�)�#�#�Z��v�$>�?�<�7�C�
��k��K�K�`�a�
��!���I�I���	�	��L�M��)�)�#�#�Z��$8�9�<�7�C�
��l��K�K�PV�X[�Xa�Xa�Xc�d�e�rc��|j�d}d}d}g}t|jj��D�]\}}|jj|�}|jj|�}	|sZ|jjd|g�\}}
|dkrd}tjd�n|dkDrtjd|z�|s|dk(s��t|	�dkDr0|	dd	d
k(r(tjdd|	�}	|j|�t|	�dkDr|d|zd
z|	zdzz
}��tjd|z���|jj!t"j$|�t|�}|dkDrN|j'|�t|j�|k7r$tj)t"j*�yyy)N�rF�modinfoTz8'modinfo' command not found, not checking kernel modulesz)kernel module '%s' not found, skipping itr�z+r�^\s*\+r\s*,?\s*zoptions � �
zKmodule '%s' doesn't have any option specified, not writing it to modprobe.d)�_clear_modprobe_file�listr�items�
_variables�expandr
r#r$r%�error�len�re�sub�appendr&�
write_to_file�consts�MODULES_FILEr,�info�STR_HINT_REBOOT)rr�sr*�
skip_check�reload_list�option�valuer)�vr+�ls            r�_instance_apply_staticz$ModulesPlugin._instance_apply_staticLs��������!�
�'��*��+��H�-�-�3�3�5�6�m�f�e��O�O�"�"�6�*�6������e�$�1�
��9�9�$�$�i��%8�9�L�G�S���{��Z��[�[�K�L�	�1���Y�Y�:�V�C�D��G�q�L�
�1�v��z�a��!�f��n�	���"�B��	*�Q������
�1�v��z��*�v�
��
#�a�
'�$�
.�.�Q��Y�Y�\�_e�e�f�#7�$�)�)���&�-�-�q�1�	�+��!���U�����$�	�(�
�
���!��H�H�V�
#�
#�$�"�rc�8�t|�jdd�S)N�/r.)�str�replace)r�paths  r�
_unquote_pathzModulesPlugin._unquote_pathks��	�T��	�	�3��	#�#rc
�n�d}d}tjd�}t|jj	��D�]t\}}|j
j
|�}|j
j
|�}	tjdd|	�}	d|z}
tjj|
�s,d}tjtjdz|z���tjtj dz|z�|j#|	�}|D]�}|j#d	d
�}
t%|
�dk7rtj'd|�d
|����?|j)|
d|
d
|j*j-|
dz|j/|
d�zdd��|�dk(s��d}����w|S)NTz\s+r1r.z/sys/module/%sFzmodule '%s' is not loadedzmodule '%s' is loaded�=rr0z'unrecognized module option for module 'r"rz/parameters/)�err_ret�no_error)r;�compiler5rr6r7r8r<�osrO�existsr$r9r?�STR_VERIFY_PROFILE_FAILrA�STR_VERIFY_PROFILE_OK�splitr:r%�
_verify_valuer
�	read_filerP)rr�ignore_missing�devices�ret�rrFrGr)rH�mpathrI�item�args              r�_instance_verify_staticz%ModulesPlugin._instance_verify_staticnsz���#��.��j�j���!��H�-�-�3�3�5�6�m�f�e��O�O�"�"�6�*�6������e�$�1�	�v�v� �"�a�(�1��f�$�5�
�'�'�.�.��
�
�C��I�I�f�,�,�/J�J�V�S�T��H�H�V�
)�
)�,C�
C�f�
L�M�	����
�A����:�:�c�1��S��C��A�
�	�k�k�f�d�S�T�	
�	�	�C��F�C��F��y�y���5�>�1�D�4F�4F�s�1�v�4N�N�Z^�ko��p��
��
 ����7�(

�*rc�L�|tjk(r|j�yyr)r?�
ROLLBACK_FULLr4)rr�rollbacks   r�_instance_unapply_staticz&ModulesPlugin._instance_unapply_static�s!��
��%�%�%�����&rc��|jjtjd��}|j	d�}dx}}t|�}t
jd�}||kr#|j||��|}|}|dz
}||kr�#dj|d|�}t|�dkDr|dz
}|jjtj|�y)NT)rTr3rz^\s*#r)r
r\r?r@rZr:r;rU�search�joinr>)rrCrI�i�j�llr`s       rr4z"ModulesPlugin._clear_modprobe_file�s���
�i�i���&�-�-�$��?�!��g�g�d�m�!�
�)�!�a�
�1�v�"��j�j���!�	�B���h�h�q��t�n��	�A�
�A���6�1�		
�B��
�i�i��!�A���!���V�a�Z���9�1��)�)���&�-�-�q�1r)�__name__�
__module__�__qualname__�__doc__rrrr,rJrPrdr?�
ROLLBACK_SOFTrhr4�
__classcell__)rs@rrrsC���$�L�
'�
�
f�%�>$�
�6:@�9M�9M��2rr)r;�os.pathrVr.r�
decorators�
tuned.logs�tuned�
subprocess�tuned.utils.commandsr�tuned.constsr?�logs�getr$�Pluginrrrr�<module>rs?��	������)���j�j�n�n���O2�D�K�K�O2r