@@ -15,10 +15,10 @@ class SystemdPlugin(base.Plugin):
1515 Plug-in for tuning systemd options.
1616
1717 The [option]`cpu_affinity` option allows setting CPUAffinity in
18- `/etc/systemd/system.conf`. This configures the CPU affinity for the
19- service manager as well as the default CPU affinity for all forked
20- off processes. The option takes a comma-separated list of CPUs with
21- optional CPU ranges specified by the minus sign (`-`).
18+ `/etc/systemd/system.conf.d/00-tuned.conf `. This configures the CPU
19+ affinity for the service manager as well as the default CPU affinity
20+ for all forked off processes. The option takes a comma-separated
21+ list of CPUs with optional CPU ranges specified by the minus sign (`-`).
2222
2323 .Set the CPUAffinity for `systemd` to `0 1 2 3`
2424 ====
@@ -32,10 +32,15 @@ class SystemdPlugin(base.Plugin):
3232 """
3333
3434 def __init__ (self , * args , ** kwargs ):
35+ self ._cmd = commands ()
3536 if not os .path .isfile (consts .SYSTEMD_SYSTEM_CONF_FILE ):
36- raise exceptions .NotSupportedPluginException ("Required systemd '%s' configuration file not found, disabling plugin." % consts .SYSTEMD_SYSTEM_CONF_FILE )
37+ if os .path .isdir (consts .SYSTEMD_CFG_PATH ):
38+ log .info ("Systemd configuration file '%s' not found, attempting to create it." % consts .SYSTEMD_SYSTEM_CONF_FILE )
39+ if not self ._cmd .write_to_file (consts .SYSTEMD_SYSTEM_CONF_FILE , consts .SYSTEMD_SYSTEM_CONF_HEADER + "\n " , makedir = True ):
40+ raise exceptions .NotSupportedPluginException ("Error creating systemd configuration file '%s', disabling plugin." % consts .SYSTEMD_SYSTEM_CONF_FILE )
41+ else :
42+ raise exceptions .NotSupportedPluginException ("Systemd directory '%s' not found, systemd is not probably used, disabling plugin." % consts .SYSTEMD_CFG_PATH )
3743 super (SystemdPlugin , self ).__init__ (* args , ** kwargs )
38- self ._cmd = commands ()
3944
4045 def _instance_init (self , instance ):
4146 instance ._has_dynamic_tuning = False
@@ -143,4 +148,3 @@ def _cmdline(self, enabling, value, verify, ignore_missing, instance):
143148 self ._write_systemd_system_conf (self ._add_keyval (conf , consts .SYSTEMD_CPUAFFINITY_VAR , v_unpacked ))
144149 return True
145150 return None
146-
0 commit comments