← Back
Editing: plugin_modules.cpython-312.pyc
� �]�i7 � � � d dl Z d dlZddlmZ ddl� d dlZd dl� d dl m Z d dlmZ ej j � Z G d� dej � Zy)� N� )�base)�*)�commandsc �j � � e Zd ZdZ� fd�Zd� Zd� Zd� Zd� Zd� Z d� Z ej fd �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 �� t t | � |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.pyr zModulesPlugin.__init__3 s( �� �� �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_init8 s � �!&�(�� $�(���&�&�(�r c � � y �N� r s r �_instance_cleanupzModulesPlugin._instance_cleanup= s � �r c � � |D ]� }| j j dd|g� \ }}|dk rt j d� y |dkD r)t j d|�d|j � ��� | j j d|g� \ }}|dk7 s��t j d|�d|j � ��� �� y ) N�modprobez-rr zN'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� r c � � | j � d}d}d}g }t |j j � � D �] \ }}| j j |� }| j j |� } |sZ| j j d|g� \ }} |dk rd}t j d� n|dkD rt j d|z � |s|dk( s��t | � dkD r0| dd d k( r(t j dd| � } |j |� t | � dkD r|d|z d z | z dz z }��t j d|z � �� | j j! t"