chiark / gitweb /
mechanisms: add mechanisms to change system locale and clock
[elogind.git] / src / cgroup.c
index 5864858dd7e7099011aebcc48ed1b128e18ab1f2..0c6f20d4b75311bfa2b8b6e5944c26cb534db8b1 100644 (file)
@@ -63,7 +63,7 @@ int cgroup_bonding_realize_list(CGroupBonding *first) {
         return 0;
 }
 
-void cgroup_bonding_free(CGroupBonding *b) {
+void cgroup_bonding_free(CGroupBonding *b, bool remove_or_trim) {
         assert(b);
 
         if (b->unit) {
@@ -82,7 +82,7 @@ void cgroup_bonding_free(CGroupBonding *b) {
                 }
         }
 
-        if (b->realized && b->ours) {
+        if (b->realized && b->ours && remove_or_trim) {
 
                 if (cgroup_bonding_is_empty(b) > 0)
                         cg_delete(b->controller, b->path);
@@ -95,11 +95,11 @@ void cgroup_bonding_free(CGroupBonding *b) {
         free(b);
 }
 
-void cgroup_bonding_free_list(CGroupBonding *first) {
+void cgroup_bonding_free_list(CGroupBonding *first, bool remove_or_trim) {
         CGroupBonding *b, *n;
 
         LIST_FOREACH_SAFE(by_unit, b, n, first)
-                cgroup_bonding_free(b);
+                cgroup_bonding_free(b, remove_or_trim);
 }
 
 void cgroup_bonding_trim(CGroupBonding *b, bool delete_root) {
@@ -225,6 +225,12 @@ int manager_setup_cgroup(Manager *m) {
 
         assert(m);
 
+        /* 0. Be nice to Ingo Molnar #628004 */
+        if (path_is_mount_point("/sys/fs/cgroup/systemd") <= 0) {
+                log_warning("No control group support available, not creating root group.");
+                return 0;
+        }
+
         /* 1. Determine hierarchy */
         if ((r = cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, 0, &current)) < 0) {
                 log_error("Cannot determine cgroup we are running in: %s", strerror(-r));