Merge pull request #13866 from keszybz/nspawn-restarts

Make 'machinectl reboot' functional
This commit is contained in:
Lennart Poettering
2019-10-30 10:53:28 +01:00
committed by GitHub
13 changed files with 122 additions and 25 deletions
+3 -3
View File
@@ -209,7 +209,7 @@ int register_machine(
return 0;
}
int terminate_machine(
int unregister_machine(
sd_bus *bus,
const char *machine_name) {
@@ -223,13 +223,13 @@ int terminate_machine(
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"TerminateMachine",
"UnregisterMachine",
&error,
NULL,
"s",
machine_name);
if (r < 0)
log_debug("Failed to terminate machine: %s", bus_error_message(&error, r));
log_debug("Failed to unregister machine: %s", bus_error_message(&error, r));
return 0;
}
+1 -1
View File
@@ -8,7 +8,7 @@
#include "nspawn-mount.h"
int register_machine(sd_bus *bus, const char *machine_name, pid_t pid, const char *directory, sd_id128_t uuid, int local_ifindex, const char *slice, CustomMount *mounts, unsigned n_mounts, int kill_signal, char **properties, sd_bus_message *properties_message, bool keep_unit, const char *service);
int terminate_machine(sd_bus *bus, const char *machine_name);
int unregister_machine(sd_bus *bus, const char *machine_name);
int allocate_scope(sd_bus *bus, const char *machine_name, pid_t pid, const char *slice, CustomMount *mounts, unsigned n_mounts, int kill_signal, char **properties, sd_bus_message *properties_message);
int terminate_scope(sd_bus *bus, const char *machine_name);
+6 -6
View File
@@ -4618,12 +4618,8 @@ static int run_container(
}
/* Kill if it is not dead yet anyway */
if (bus) {
if (arg_register)
terminate_machine(bus, arg_machine);
else if (!arg_keep_unit)
terminate_scope(bus, arg_machine);
}
if (!arg_register && !arg_keep_unit && bus)
terminate_scope(bus, arg_machine);
/* Normally redundant, but better safe than sorry */
(void) kill(*pid, SIGKILL);
@@ -4631,6 +4627,10 @@ static int run_container(
r = wait_for_container(*pid, &container_status);
*pid = 0;
/* Tell machined that we are gone. */
if (bus)
(void) unregister_machine(bus, arg_machine);
if (r < 0)
/* We failed to wait for the container, or the container exited abnormally. */
return r;