diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-10-07 14:50:11 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-11-09 17:15:34 +0100 |
commit | b92d0b4c5adef37e9de8f6cc22a0e27b97fcf3ad (patch) | |
tree | 767d4e94958f6f530da1b95c349a6d4ed8b26591 /src/machine/machined-dbus.c | |
parent | nspawn: rework how we allocate/kill scopes (diff) | |
download | systemd-b92d0b4c5adef37e9de8f6cc22a0e27b97fcf3ad.tar.xz systemd-b92d0b4c5adef37e9de8f6cc22a0e27b97fcf3ad.zip |
machined: rework referencing of machine scopes from machined, too
When a machine scope is registered by machined, let's add a reference to
it, and change the GC mode so that the unit is cleaned up as soon as
machined drops the reference, regardless of the fail state.
Fixes: #2809
Diffstat (limited to 'src/machine/machined-dbus.c')
-rw-r--r-- | src/machine/machined-dbus.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 32c0b04283..87e6298c78 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -1363,18 +1363,15 @@ int manager_start_scope( return r; } - r = sd_bus_message_append(m, "(sv)", "PIDs", "au", 1, pid); + r = sd_bus_message_append(m, "(sv)(sv)(sv)(sv)(sv)", + "PIDs", "au", 1, pid, + "Delegate", "b", 1, + "CollectMode", "s", "inactive-or-failed", + "AddRef", "b", 1, + "TasksMax", "t", UINT64_C(16384)); if (r < 0) return r; - r = sd_bus_message_append(m, "(sv)", "Delegate", "b", 1); - if (r < 0) - return r; - - r = sd_bus_message_append(m, "(sv)", "TasksMax", "t", UINT64_C(16384)); - if (r < 0) - return bus_log_create_error(r); - if (more_properties) { r = sd_bus_message_copy(m, more_properties, true); if (r < 0) @@ -1411,6 +1408,26 @@ int manager_start_scope( return 1; } +int manager_unref_unit( + Manager *m, + const char *unit, + sd_bus_error *error) { + + assert(m); + assert(unit); + + return sd_bus_call_method( + m->bus, + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "UnrefUnit", + error, + NULL, + "s", + unit); +} + int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job) { _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; int r; |