[systemd-commits] 3 commits - man/pam_systemd.xml man/systemd.conf.xml src/build.h src/dbus-manager.c src/main.c src/manager.c src/manager.h src/system.conf src/unit.c
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Nov 17 15:43:15 PST 2010
man/pam_systemd.xml | 20 +++++++++++++++
man/systemd.conf.xml | 15 +++++++++++
src/build.h | 8 +++++-
src/dbus-manager.c | 7 +++--
src/main.c | 7 +++++
src/manager.c | 19 ++++++++++++++
src/manager.h | 2 +
src/system.conf | 1
src/unit.c | 66 +++++++++++++++++++++++++++------------------------
9 files changed, 112 insertions(+), 33 deletions(-)
New commits:
commit 06d4c99ab3d479c1a7c087a87e82fe01626128f6
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 18 00:42:35 2010 +0100
manager: make list of default controllers configurable
diff --git a/man/systemd.conf.xml b/man/systemd.conf.xml
index 6759f97..32eae2b 100644
--- a/man/systemd.conf.xml
+++ b/man/systemd.conf.xml
@@ -112,6 +112,21 @@
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>
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index d1d3b47..28986e5 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -167,7 +167,9 @@
" <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 \
@@ -319,7 +321,8 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
{ "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 },
diff --git a/src/main.c b/src/main.c
index 4bdc676..99e277c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -49,6 +49,7 @@
#include "missing.h"
#include "label.h"
#include "build.h"
+#include "strv.h"
static enum {
ACTION_RUN,
@@ -72,6 +73,7 @@ static bool arg_sysv_console = true;
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;
@@ -502,6 +504,7 @@ static int parse_config_file(void) {
{ "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 }
};
@@ -1089,6 +1092,9 @@ int main(int argc, char *argv[]) {
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));
@@ -1211,6 +1217,7 @@ finish:
free(arg_default_unit);
free(arg_console);
+ strv_free(arg_default_controllers);
dbus_shutdown();
diff --git a/src/manager.c b/src/manager.c
index 827e993..6284706 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -222,6 +222,9 @@ int manager_new(ManagerRunningAs running_as, Manager **_m) {
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;
@@ -461,6 +464,8 @@ void manager_free(Manager *m) {
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);
@@ -2988,6 +2993,20 @@ void manager_undo_generators(Manager *m) {
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"
diff --git a/src/manager.h b/src/manager.h
index c7ace2d..f9c769e 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -142,6 +142,7 @@ struct Manager {
Set *unit_path_cache;
char **environment;
+ char **default_controllers;
dual_timestamp initrd_timestamp;
dual_timestamp startup_timestamp;
@@ -256,6 +257,7 @@ unsigned manager_dispatch_run_queue(Manager *m);
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);
diff --git a/src/system.conf b/src/system.conf
index c6a7bf3..c94cf36 100644
--- a/src/system.conf
+++ b/src/system.conf
@@ -20,3 +20,4 @@
#CPUAffinity=1 2
#MountAuto=yes
#SwapAuto=yes
+#DefaultControllers=cpu
diff --git a/src/unit.c b/src/unit.c
index bfb1dd6..7d673e1 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -1785,55 +1785,61 @@ fail:
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);
commit 7838dc3ae1297d37c2a75a48f429bb415c1eed22
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 18 00:39:09 2010 +0100
build: expose libcryptsetup dependency in build string
diff --git a/src/build.h b/src/build.h
index 04ac639..50cd79d 100644
--- a/src/build.h
+++ b/src/build.h
@@ -52,6 +52,12 @@
#define _SYSVINIT_FEATURE_ "-SYSVINIT"
#endif
-#define SYSTEMD_FEATURES _PAM_FEATURE_ " " _LIBWRAP_FEATURE_ " " _AUDIT_FEATURE_ " " _SELINUX_FEATURE_ " " _SYSVINIT_FEATURE_
+#ifdef HAVE_LIBCRYPTSETUP
+#define _LIBCRYPTSETUP_FEATURE_ "+LIBCRYPTSETUP"
+#else
+#define _LIBCRYPTSETUP_FEATURE_ "-LIBCRYPTSETUP"
+#endif
+
+#define SYSTEMD_FEATURES _PAM_FEATURE_ " " _LIBWRAP_FEATURE_ " " _AUDIT_FEATURE_ " " _SELINUX_FEATURE_ " " _SYSVINIT_FEATURE_ " " _LIBCRYPTSETUP_FEATURE_
#endif
commit 4611d77694effd27ad0e191c820498dbff25907c
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 18 00:38:41 2010 +0100
pam: document controllers= switch
diff --git a/man/pam_systemd.xml b/man/pam_systemd.xml
index 3dc3714..d43ed23 100644
--- a/man/pam_systemd.xml
+++ b/man/pam_systemd.xml
@@ -200,6 +200,26 @@
terminated only on their complete
logout.</para></listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><option>controllers=</option></term>
+
+ <listitem><para>Takes a comma
+ seperated list of cgroup controllers
+ in which hierarchies a user/session
+ cgroup will be created by defautl for
+ each user logging in. If ommited,
+ defaults to 'cpu', meaning that in
+ addition to creating per-user and
+ per-session cgroups in systemd's own
+ hierarchy, groups are created in the
+ 'cpu' hierarchy, on order to ensure
+ that every use and every sessions gets
+ an equal amount of CPU time,
+ regardless how many processes a user
+ or session might
+ own.</para></listitem>
+ </varlistentry>
</variablelist>
<para>Note that setting <varname>kill-user=1</varname>
More information about the systemd-commits
mailing list