VULN_CHECK_I913V6 GiGddlmZddlddlZddlmZddlmZddlm Z ddl Z ddl Z ejjZGddejZy) )base)*N) exceptions)commandsceZdZdZfdZdZdZedZdZ dZ dZ d Z d Z d Zd Zej"fd ZdZedddZxZS) SystemdPlugina' Plug-in for tuning systemd options. The [option]`cpu_affinity` option allows setting CPUAffinity in `/etc/systemd/system.conf`. This configures the CPU affinity for the service manager as well as the default CPU affinity for all forked off processes. The option takes a comma-separated list of CPUs with optional CPU ranges specified by the minus sign (`-`). .Set the CPUAffinity for `systemd` to `0 1 2 3` ==== ---- [systemd] cpu_affinity=0-3 ---- ==== NOTE: These tunings are unloaded only on profile change followed by a reboot. ctjjtjs&t j dtjztt|&|i|t|_ y)NzERequired systemd '%s' configuration file not found, disabling plugin.) ospathisfileconstsSYSTEMD_SYSTEM_CONF_FILErNotSupportedPluginExceptionsuperr __init__r_cmd)selfargskwargs __class__s A/usr/lib/python3.12/site-packages/tuned/plugins/plugin_systemd.pyrzSystemdPlugin.__init__"si 77 8  / /0w{A{Z{Z1Z [[ t%t6v6j$)c d|_d|_y)NFT)_has_dynamic_tuning_has_static_tuningrinstances r_instance_initzSystemdPlugin._instance_init(s!&( $(rcyNrs r_instance_cleanupzSystemdPlugin._instance_cleanup,src ddiS)N cpu_affinityr")clss r_get_config_optionsz!SystemdPlugin._get_config_options/s4 rc|Ntjd|zdz|tj}| |jdk(r|j dSy)N^\s*z \s*=\s*(.*)$flagsr)research MULTILINE lastindexgroup)rconfkeymos r _get_keyvalzSystemdPlugin._get_keyval5sH  'C-/14N2n* 88A; rctjd|zdzdt|z|tj\}}|dkr' |ddk7r|dz }||dzt|zdzz }|S|S#t$rY&wxYw) Nz^(\s*z\s*=).*$z\g<1>r*r =)r,subnstrr. IndexError)rr1r2valconf_newnsubss r _add_keyvalzSystemdPlugin._add_keyval=sgghn{:Hs3xA`A` `a99G-  rcrtjjtj|j Sr!)r r joinrPERSISTENT_STORAGE_DIRname)rs r_get_storage_filenamez#SystemdPlugin._get_storage_filenameas! f33TYY ??rcf|j}||j}|jj|dd}|jj ||!|j |t j}n!|j|t j|}|j|yy)NTrErL) rJrWrrFrOrCrSYSTEMD_CPUAFFINITY_VARr?rR)rr1fnamecpu_affinity_saveds r_remove_systemd_tuningz$SystemdPlugin._remove_systemd_tuningds ' ' )$   % % '5 ++ETd+S99E ==v== >D   D&"@"@BT UD""4(rc|tjk(rLtjdtjz|j tj dyy)Nz6removing '%s' systemd tuning previously added by TuneDz[you may need to manualy run 'dracut -f' to update the systemd configuration in initrd image)r ROLLBACK_FULLrGinforZr]console)rrrollbacks r_instance_unapply_staticz&SystemdPlugin._instance_unapply_staticpsF %%%88 DvGeGe ef ;;lm&rc|ydjd|jjtjddtjdd|DS)NrA c32K|]}t|ywr!r:.0vs r z8SystemdPlugin._cpulist_convert_unpack..zsq"pQ#a&"pz\s+,z,\s+)rTrcpulist_unpackr,rB)rcpulists r_cpulist_convert_unpackz%SystemdPlugin._cpulist_convert_unpackwsN _ q$))":":266&$PRPVPVW^`dfmPn;o"pq qqrr%F) per_devicec @d}d}|jj|jj|jj |}dj d|jj |D} |j} | 1|j| tj}|j|}|r|jd| ||S|r|j} |jj| dd} |%| #| |k7r|jj| |dt j#dtjd| d tj$d |j'|j)| tj| yy) Nrec32K|]}t|ywr!rgrhs rrkz)SystemdPlugin._cmdline..sD(C1A(Crlr%TrY)makedirz setting 'z' to 'z ' in the '')runescape _variablesexpandunquoterTrnrJr4rrZrp _verify_valuerWrFrNrGr`rrRr?) renablingvalueverifyignore_missingr conf_affinityconf_affinity_unpackedrj v_unpackedr1r[r\s r_cmdlinezSystemdPlugin._cmdline|s`- ii// 0A0A%0HIJ!xxD (@(@(CDD* ' ' )$ ##D&*H*HI= 88G   ^Z9OQ_ ``  % % '5 ++ETd+S$6$>:QgCgIIE=DA88&2P2PR\^d^}^} ~""4#3#3D&:X:XZd#ef  r)__name__ __module__ __qualname____doc__rrr# classmethodr'r4r?rCrJrRrWr]r ROLLBACK_SOFTrcrpcommand_customr __classcell__)rs@rr r s( %  M @ ):@9M9Mnr e45rr )rAr decorators tuned.logstunedrtuned.utils.commandsr tuned.constsrr r,logsgetrGPluginr r"rrrs?)  jjnnDDKKDr