diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-07-03 12:48:51 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-07-03 12:51:07 +0200 |
commit | 206e7a5f7b55ac61188efd895e65ab26e478cbb2 (patch) | |
tree | e67415e2fd5fd8aa281548200cc5fd327c1e3b97 | |
parent | 37520c1bec9a92adbe02fceaece588a7aa2fea2b (diff) |
machined: don't force terminate registered machines
When a machine is registered in machined with CreateMachine it is OK to
kill the machine when it is terminated, but when an existing unit is
simply registered via RegisterMachine we shouldn't do that, as the unit
is controlled by somebody else.
-rw-r--r-- | src/machine/machine.c | 10 | ||||
-rw-r--r-- | src/machine/machine.h | 1 | ||||
-rw-r--r-- | src/machine/machined-dbus.c | 1 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/machine/machine.c b/src/machine/machine.c index 0b0d45bb2..c0fa1b24b 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -360,10 +360,12 @@ static int machine_stop_scope(Machine *m) { if (!m->unit) return 0; - r = manager_stop_unit(m->manager, m->unit, &error, &job); - if (r < 0) { - log_error("Failed to stop machine scope: %s", bus_error_message(&error, r)); - return r; + if (!m->registered) { + r = manager_stop_unit(m->manager, m->unit, &error, &job); + if (r < 0) { + log_error("Failed to stop machine scope: %s", bus_error_message(&error, r)); + return r; + } } free(m->scope_job); diff --git a/src/machine/machine.h b/src/machine/machine.h index a894a463a..ed1c81c4f 100644 --- a/src/machine/machine.h +++ b/src/machine/machine.h @@ -72,6 +72,7 @@ struct Machine { bool in_gc_queue:1; bool started:1; + bool registered:1; sd_bus_message *create_message; diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 6f8ba474f..7c1802ce2 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -223,6 +223,7 @@ static int method_create_or_register_machine(Manager *manager, sd_bus_message *m m->leader = leader; m->class = c; m->id = id; + m->registered = true; if (!isempty(service)) { m->service = strdup(service); |