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.
This commit is contained in:
parent
37520c1bec
commit
206e7a5f7b
|
@ -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);
|
||||
|
|
|
@ -72,6 +72,7 @@ struct Machine {
|
|||
|
||||
bool in_gc_queue:1;
|
||||
bool started:1;
|
||||
bool registered:1;
|
||||
|
||||
sd_bus_message *create_message;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue