/***
This file is part of systemd.
Copyright 2013 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include "alloc-util.h"
#include "dbus-slice.h"
#include "log.h"
#include "slice.h"
#include "special.h"
#include "string-util.h"
#include "strv.h"
#include "unit-name.h"
#include "unit.h"
[SLICE_DEAD] = UNIT_INACTIVE,
};
assert(t);
log_debug("%s changed %s -> %s",
}
char *a, *dash;
int r;
assert(s);
return 0;
return 0;
if (dash)
else
a = (char*) SPECIAL_ROOT_SLICE;
if (r < 0)
return r;
return 0;
}
int r;
assert(s);
if (!UNIT(s)->default_dependencies)
return 0;
/* Make sure slices are unloaded on shutdown */
UNIT(s),
SPECIAL_SHUTDOWN_TARGET, NULL, true);
if (r < 0)
return r;
return 0;
}
int r;
assert(s);
return 0;
return -EINVAL;
}
if (r < 0)
return -EINVAL;
}
return 0;
}
int r;
assert(s);
if (r < 0)
return r;
/* This is a new unit? Then let's add in some extras */
if (u->load_state == UNIT_LOADED) {
r = unit_patch_contexts(u);
if (r < 0)
return r;
r = slice_add_parent_slice(s);
if (r < 0)
return r;
r = slice_add_default_dependencies(s);
if (r < 0)
return r;
}
return slice_verify(s);
}
assert(t);
if (t->deserialized_state != t->state)
slice_set_state(t, t->deserialized_state);
return 0;
}
assert(t);
assert(f);
fprintf(f,
"%sSlice State: %s\n",
}
assert(t);
(void) unit_realize_cgroup(u);
(void) unit_reset_cpu_usage(u);
return 1;
}
assert(t);
/* We do not need to destroy the cgroup explicitly,
* unit_notify() will do that for us anyway. */
return 1;
}
}
assert(s);
assert(f);
return 0;
}
assert(u);
if (state < 0)
else
s->deserialized_state = state;
} else
return 0;
}
assert(u);
}
assert(u);
}
Unit *u;
int r;
assert(m);
u = manager_get_unit(m, SPECIAL_ROOT_SLICE);
if (!u) {
if (!u) {
log_oom();
return;
}
r = unit_add_name(u, SPECIAL_ROOT_SLICE);
if (r < 0) {
unit_free(u);
log_error_errno(r, "Failed to add -.slice name");
return;
}
}
u->default_dependencies = false;
u->no_gc = true;
u->ignore_on_isolate = true;
u->refuse_manual_start = true;
u->refuse_manual_stop = true;
if (!u->description)
if (!u->documentation)
}
.object_size = sizeof(Slice),
.sections =
"Unit\0"
"Slice\0"
"Install\0",
.private_section = "Slice",
.no_alias = true,
.no_instances = true,
.can_transient = true,
.load = slice_load,
.dump = slice_dump,
.start = slice_start,
.stop = slice_stop,
.kill = slice_kill,
.finished_start_job = {
[JOB_DONE] = "Created slice %s.",
},
.finished_stop_job = {
[JOB_DONE] = "Removed slice %s.",
},
},
};