whether this job is left to some other
system script.</para></listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><varname>DefaultControllers=cpu</varname></term>
+
+ <listitem><para>Configures in which
+ cgroup controller hierarchies to
+ create per-service cgroups
+ automatically, in addition to the
+ name=systemd named hierarchy. Defaults
+ to 'cpu'. Takes a space seperated list
+ of controller names. Pass an empty
+ string to ensure that systemd does not
+ touch any hiearchies but its
+ own.</para></listitem>
+ </varlistentry>
</variablelist>
</refsect1>
" <property name=\"NotifySocket\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"ControlGroupHierarchy\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"MountAuto\" type=\"b\" access=\"read\"/>\n" \
- " <property name=\"SwapAuto\" type=\"b\" access=\"read\"/>\n"
+ " <property name=\"SwapAuto\" type=\"b\" access=\"read\"/>\n" \
+ " <property name=\"DefaultControllers\" type=\"as\" access=\"read\"/>\n"
+ \
#ifdef HAVE_SYSV_COMPAT
#define BUS_MANAGER_INTERFACE_PROPERTIES_SYSV \
{ "org.freedesktop.systemd1.Manager", "NotifySocket", bus_property_append_string, "s", m->notify_socket },
{ "org.freedesktop.systemd1.Manager", "ControlGroupHierarchy", bus_property_append_string, "s", m->cgroup_hierarchy },
{ "org.freedesktop.systemd1.Manager", "MountAuto", bus_property_append_bool, "b", &m->mount_auto },
- { "org.freedesktop.systemd1.Manager", "SwapAuto", bus_property_append_bool, "b", &m->swap_auto },
+ { "org.freedesktop.systemd1.Manager", "SwapAuto", bus_property_append_bool, "b", &m->swap_auto },
+ { "org.freedesktop.systemd1.Manager", "DefaultControllers", bus_property_append_strv, "as", m->default_controllers },
#ifdef HAVE_SYSV_COMPAT
{ "org.freedesktop.systemd1.Manager", "SysVConsole", bus_property_append_bool, "b", &m->sysv_console },
{ "org.freedesktop.systemd1.Manager", "SysVInitPath", bus_property_append_strv, "as", m->lookup_paths.sysvinit_path },
#include "missing.h"
#include "label.h"
#include "build.h"
+#include "strv.h"
static enum {
ACTION_RUN,
static bool arg_mount_auto = true;
static bool arg_swap_auto = true;
static char *arg_console = NULL;
+static char **arg_default_controllers = NULL;
static FILE* serialization = NULL;
{ "CPUAffinity", config_parse_cpu_affinity, NULL, "Manager" },
{ "MountAuto", config_parse_bool, &arg_mount_auto, "Manager" },
{ "SwapAuto", config_parse_bool, &arg_swap_auto, "Manager" },
+ { "DefaultControllers", config_parse_strv, &arg_default_controllers, "Manager" },
{ NULL, NULL, NULL, NULL }
};
if (arg_console)
manager_set_console(m, arg_console);
+ if (arg_default_controllers)
+ manager_set_default_controllers(m, arg_default_controllers);
+
if ((r = manager_startup(m, serialization, fds)) < 0)
log_error("Failed to fully start up daemon: %s", strerror(-r));
free(arg_default_unit);
free(arg_console);
+ strv_free(arg_default_controllers);
dbus_shutdown();
if (!(m->environment = strv_copy(environ)))
goto fail;
+ if (!(m->default_controllers = strv_new("cpu", NULL)))
+ goto fail;
+
if (!(m->units = hashmap_new(string_hash_func, string_compare_func)))
goto fail;
lookup_paths_free(&m->lookup_paths);
strv_free(m->environment);
+ strv_free(m->default_controllers);
+
hashmap_free(m->cgroup_bondings);
set_free_free(m->unit_path_cache);
m->generator_unit_path = NULL;
}
+int manager_set_default_controllers(Manager *m, char **controllers) {
+ char **l;
+
+ assert(m);
+
+ if (!(l = strv_copy(controllers)))
+ return -ENOMEM;
+
+ strv_free(m->default_controllers);
+ m->default_controllers = l;
+
+ return 0;
+}
+
static const char* const manager_running_as_table[_MANAGER_RUNNING_AS_MAX] = {
[MANAGER_SYSTEM] = "system",
[MANAGER_USER] = "user"
Set *unit_path_cache;
char **environment;
+ char **default_controllers;
dual_timestamp initrd_timestamp;
dual_timestamp startup_timestamp;
unsigned manager_dispatch_dbus_queue(Manager *m);
int manager_set_console(Manager *m, const char *console);
+int manager_set_default_controllers(Manager *m, char **controllers);
int manager_loop(Manager *m);
#CPUAffinity=1 2
#MountAuto=yes
#SwapAuto=yes
+#DefaultControllers=cpu
return r;
}
-int unit_add_default_cgroups(Unit *u) {
+static int unit_add_one_default_cgroup(Unit *u, const char *controller) {
CGroupBonding *b = NULL;
int r = -ENOMEM;
- const char * const default_controllers[] = {
- SYSTEMD_CGROUP_CONTROLLER,
- "cpu",
- NULL
- };
- const char * const*c;
assert(u);
- /* Adds in the default cgroups, if it wasn't specified yet */
-
- STRV_FOREACH(c, default_controllers) {
-
- if (cgroup_bonding_find_list(u->meta.cgroup_bondings, *c))
- continue;
+ if (!controller)
+ controller = SYSTEMD_CGROUP_CONTROLLER;
- if (!(b = new0(CGroupBonding, 1)))
- return -ENOMEM;
+ if (cgroup_bonding_find_list(u->meta.cgroup_bondings, controller))
+ return 0;
- if (!(b->path = default_cgroup_path(u)))
- goto fail;
+ if (!(b = new0(CGroupBonding, 1)))
+ return -ENOMEM;
- if (!(b->controller = strdup(*c)))
- goto fail;
+ if (!(b->controller = strdup(controller)))
+ goto fail;
- b->ours = true;
- b->essential = c == default_controllers; /* the first one is essential */
+ if (!(b->path = default_cgroup_path(u)))
+ goto fail;
- if ((r = unit_add_cgroup(u, b)) < 0)
- goto fail;
+ b->ours = true;
+ b->essential = streq(controller, SYSTEMD_CGROUP_CONTROLLER);
- b = NULL;
- }
+ if ((r = unit_add_cgroup(u, b)) < 0)
+ goto fail;
return 0;
fail:
- if (b) {
- free(b->path);
- free(b->controller);
- free(b);
- }
+ free(b->path);
+ free(b->controller);
+ free(b);
return r;
}
+int unit_add_default_cgroups(Unit *u) {
+ char **c;
+ int r;
+ assert(u);
+
+ /* Adds in the default cgroups, if they weren't specified
+ * otherwise. */
+
+ if ((r = unit_add_one_default_cgroup(u, NULL)) < 0)
+ return r;
+
+ STRV_FOREACH(c, u->meta.manager->default_controllers)
+ if ((r = unit_add_one_default_cgroup(u, *c)) < 0)
+ return r;
+
+ return 0;
+}
+
CGroupBonding* unit_get_default_cgroup(Unit *u) {
assert(u);