The rationale for this is that libvirt first creates the machine on machined and then starts the init process of the container. In such a case, the leader pid can't be the proper one when registering the machine and it needs to be updated as soon as the init process is started. --- src/machine/machined-dbus.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 0078a27..b7b5124 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -387,6 +387,31 @@ static int method_get_machine_addresses(sd_bus *bus, sd_bus_message *message, vo return bus_machine_method_get_addresses(bus, message, machine, error); } +static int method_update_machine_leader(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { + Manager *m = userdata; + Machine *machine; + const char *name; + uint32_t leader; + int r; + + assert(bus); + assert(message); + assert(m); + + r = sd_bus_message_read(message, "su", &name, &leader); + if (r < 0) + return sd_bus_error_set_errno(error, r); + + machine = hashmap_get(m->machines, name); + if (!machine) + return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); + + machine->leader = leader; + machine_save(machine); + + return sd_bus_reply_method_return(message, NULL); +} + const sd_bus_vtable manager_vtable[] = { SD_BUS_VTABLE_START(0), SD_BUS_METHOD("GetMachine", "s", "o", method_get_machine, SD_BUS_VTABLE_UNPRIVILEGED), @@ -397,6 +422,7 @@ const sd_bus_vtable manager_vtable[] = { SD_BUS_METHOD("KillMachine", "ssi", NULL, method_kill_machine, SD_BUS_VTABLE_CAPABILITY(CAP_KILL)), SD_BUS_METHOD("TerminateMachine", "s", NULL, method_terminate_machine, SD_BUS_VTABLE_CAPABILITY(CAP_KILL)), SD_BUS_METHOD("GetMachineAddresses", "s", "a(yay)", method_get_machine_addresses, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_METHOD("UpdateMachineLeader", "su", NULL, method_update_machine_leader, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_SIGNAL("MachineNew", "so", 0), SD_BUS_SIGNAL("MachineRemoved", "so", 0), SD_BUS_VTABLE_END -- 1.8.4.5 _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel