From 206e7a5f7b55ac61188efd895e65ab26e478cbb2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 3 Jul 2014 12:48:51 +0200 Subject: 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. --- src/machine/machine.c | 10 ++++++---- src/machine/machine.h | 1 + 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); -- cgit v1.2.3