summaryrefslogtreecommitdiff
path: root/src/run
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-07-01 03:02:42 +0200
committerLennart Poettering <lennart@poettering.net>2013-07-01 03:02:42 +0200
commitc221420be8744bb0f8b8a8145efc1f247f1aa801 (patch)
tree42b955f8da918c714bca4a31bfdd7067ef628277 /src/run
parentd28e9236e79e2d0a49aba472f86f7551ce9ca2f1 (diff)
core: add support to run transient units in arbitrary slices
Diffstat (limited to 'src/run')
-rw-r--r--src/run/run.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/run/run.c b/src/run/run.c
index 98c3af058f..e5a62d9e35 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -33,6 +33,7 @@ static bool arg_scope = false;
static bool arg_user = false;
static const char *arg_unit = NULL;
static const char *arg_description = NULL;
+static const char *arg_slice = NULL;
static int help(void) {
@@ -43,7 +44,8 @@ static int help(void) {
" --user Run as user unit\n"
" --scope Run this as scope rather than service\n"
" --unit=UNIT Run under the specified unit name\n"
- " --description=TEXT Description for unit\n",
+ " --description=TEXT Description for unit\n"
+ " --slice=SLICE Run in the specified slice\n",
program_invocation_short_name);
return 0;
@@ -56,7 +58,8 @@ static int parse_argv(int argc, char *argv[]) {
ARG_USER,
ARG_SCOPE,
ARG_UNIT,
- ARG_DESCRIPTION
+ ARG_DESCRIPTION,
+ ARG_SLICE
};
static const struct option options[] = {
@@ -66,6 +69,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "scope", no_argument, NULL, ARG_SCOPE },
{ "unit", required_argument, NULL, ARG_UNIT },
{ "description", required_argument, NULL, ARG_DESCRIPTION },
+ { "slice", required_argument, NULL, ARG_SLICE },
{ NULL, 0, NULL, 0 },
};
@@ -103,6 +107,10 @@ static int parse_argv(int argc, char *argv[]) {
arg_description = optarg;
break;
+ case ARG_SLICE:
+ arg_slice = optarg;
+ break;
+
case '?':
return -EINVAL;
@@ -147,6 +155,18 @@ static int message_start_transient_unit_new(sd_bus *bus, const char *name, sd_bu
if (r < 0)
return r;
+ if (!isempty(arg_slice)) {
+ _cleanup_free_ char *slice;
+
+ slice = unit_name_mangle_with_suffix(arg_slice, ".slice");
+ if (!slice)
+ return -ENOMEM;
+
+ r = sd_bus_message_append(m, "(sv)", "Slice", "s", slice);
+ if (r < 0)
+ return r;
+ }
+
*ret = m;
m = NULL;