1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2011 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
28 #include "sd-messages.h"
31 #include "path-util.h"
33 #include "fileio-label.h"
36 #include "unit-name.h"
38 #include "bus-common-errors.h"
39 #include "time-util.h"
40 #include "cgroup-util.h"
41 #include "machine-image.h"
42 #include "image-dbus.h"
44 #include "machine-dbus.h"
46 static int method_get_machine(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
47 _cleanup_free_ char *p = NULL;
48 Manager *m = userdata;
57 r = sd_bus_message_read(message, "s", &name);
61 machine = hashmap_get(m->machines, name);
63 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name);
65 p = machine_bus_path(machine);
69 return sd_bus_reply_method_return(message, "o", p);
72 static int method_get_image(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
73 _cleanup_free_ char *p = NULL;
74 Manager *m = userdata;
82 r = sd_bus_message_read(message, "s", &name);
86 r = image_find(name, NULL);
88 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_IMAGE, "No image '%s' known", name);
92 p = image_bus_path(name);
96 return sd_bus_reply_method_return(message, "o", p);
99 static int method_get_machine_by_pid(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
100 _cleanup_free_ char *p = NULL;
101 Manager *m = userdata;
102 Machine *machine = NULL;
110 assert_cc(sizeof(pid_t) == sizeof(uint32_t));
112 r = sd_bus_message_read(message, "u", &pid);
117 _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
119 r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_PID, &creds);
123 r = sd_bus_creds_get_pid(creds, &pid);
128 r = manager_get_machine_by_pid(m, pid, &machine);
132 return sd_bus_error_setf(error, BUS_ERROR_NO_MACHINE_FOR_PID, "PID "PID_FMT" does not belong to any known machine", pid);
134 p = machine_bus_path(machine);
138 return sd_bus_reply_method_return(message, "o", p);
141 static int method_list_machines(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
142 _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
143 Manager *m = userdata;
152 r = sd_bus_message_new_method_return(message, &reply);
154 return sd_bus_error_set_errno(error, r);
156 r = sd_bus_message_open_container(reply, 'a', "(ssso)");
158 return sd_bus_error_set_errno(error, r);
160 HASHMAP_FOREACH(machine, m->machines, i) {
161 _cleanup_free_ char *p = NULL;
163 p = machine_bus_path(machine);
167 r = sd_bus_message_append(reply, "(ssso)",
169 strempty(machine_class_to_string(machine->class)),
173 return sd_bus_error_set_errno(error, r);
176 r = sd_bus_message_close_container(reply);
178 return sd_bus_error_set_errno(error, r);
180 return sd_bus_send(bus, reply, NULL);
183 static int method_create_or_register_machine(Manager *manager, sd_bus_message *message, bool read_network, Machine **_m, sd_bus_error *error) {
184 const char *name, *service, *class, *root_directory;
185 const int32_t *netif = NULL;
191 size_t n, n_netif = 0;
198 r = sd_bus_message_read(message, "s", &name);
201 if (!machine_name_is_valid(name))
202 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine name");
204 r = sd_bus_message_read_array(message, 'y', &v, &n);
212 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine ID parameter");
214 r = sd_bus_message_read(message, "ssus", &service, &class, &leader, &root_directory);
221 r = sd_bus_message_read_array(message, 'i', (const void**) &netif, &n_netif);
225 n_netif /= sizeof(int32_t);
227 for (i = 0; i < n_netif; i++) {
229 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid network interface index %i", netif[i]);
234 c = _MACHINE_CLASS_INVALID;
236 c = machine_class_from_string(class);
238 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine class parameter");
242 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid leader PID");
244 if (!isempty(root_directory) && !path_is_absolute(root_directory))
245 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Root directory must be empty or an absolute path");
248 _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
250 r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_PID, &creds);
254 assert_cc(sizeof(uint32_t) == sizeof(pid_t));
256 r = sd_bus_creds_get_pid(creds, (pid_t*) &leader);
261 if (hashmap_get(manager->machines, name))
262 return sd_bus_error_setf(error, BUS_ERROR_MACHINE_EXISTS, "Machine '%s' already exists", name);
264 r = manager_add_machine(manager, name, &m);
272 if (!isempty(service)) {
273 m->service = strdup(service);
280 if (!isempty(root_directory)) {
281 m->root_directory = strdup(root_directory);
282 if (!m->root_directory) {
289 assert_cc(sizeof(int32_t) == sizeof(int));
290 m->netif = memdup(netif, sizeof(int32_t) * n_netif);
296 m->n_netif = n_netif;
304 machine_add_to_gc_queue(m);
308 static int method_create_machine_internal(sd_bus *bus, sd_bus_message *message, bool read_network, void *userdata, sd_bus_error *error) {
309 Manager *manager = userdata;
313 r = method_create_or_register_machine(manager, message, read_network, &m, error);
317 r = sd_bus_message_enter_container(message, 'a', "(sv)");
321 r = machine_start(m, message, error);
325 m->create_message = sd_bus_message_ref(message);
329 machine_add_to_gc_queue(m);
333 static int method_create_machine_with_network(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
334 return method_create_machine_internal(bus, message, true, userdata, error);
337 static int method_create_machine(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
338 return method_create_machine_internal(bus, message, false, userdata, error);
341 static int method_register_machine_internal(sd_bus *bus, sd_bus_message *message, bool read_network, void *userdata, sd_bus_error *error) {
342 Manager *manager = userdata;
343 _cleanup_free_ char *p = NULL;
347 r = method_create_or_register_machine(manager, message, read_network, &m, error);
351 r = cg_pid_get_unit(m->leader, &m->unit);
353 r = sd_bus_error_set_errnof(error, r, "Failed to determine unit of process "PID_FMT" : %s", m->leader, strerror(-r));
357 r = machine_start(m, NULL, error);
361 p = machine_bus_path(m);
367 return sd_bus_reply_method_return(message, "o", p);
370 machine_add_to_gc_queue(m);
374 static int method_register_machine_with_network(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
375 return method_register_machine_internal(bus, message, true, userdata, error);
378 static int method_register_machine(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
379 return method_register_machine_internal(bus, message, false, userdata, error);
382 static int method_terminate_machine(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
383 Manager *m = userdata;
392 r = sd_bus_message_read(message, "s", &name);
394 return sd_bus_error_set_errno(error, r);
396 machine = hashmap_get(m->machines, name);
398 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name);
400 return bus_machine_method_terminate(bus, message, machine, error);
403 static int method_kill_machine(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
404 Manager *m = userdata;
413 r = sd_bus_message_read(message, "s", &name);
415 return sd_bus_error_set_errno(error, r);
417 machine = hashmap_get(m->machines, name);
419 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name);
421 return bus_machine_method_kill(bus, message, machine, error);
424 static int method_get_machine_addresses(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
425 Manager *m = userdata;
434 r = sd_bus_message_read(message, "s", &name);
436 return sd_bus_error_set_errno(error, r);
438 machine = hashmap_get(m->machines, name);
440 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name);
442 return bus_machine_method_get_addresses(bus, message, machine, error);
445 static int method_get_machine_os_release(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
446 Manager *m = userdata;
455 r = sd_bus_message_read(message, "s", &name);
457 return sd_bus_error_set_errno(error, r);
459 machine = hashmap_get(m->machines, name);
461 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name);
463 return bus_machine_method_get_os_release(bus, message, machine, error);
466 static int method_list_images(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
467 _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
468 _cleanup_(image_hashmap_freep) Hashmap *images = NULL;
469 Manager *m = userdata;
478 images = hashmap_new(&string_hash_ops);
482 r = image_discover(images);
486 r = sd_bus_message_new_method_return(message, &reply);
490 r = sd_bus_message_open_container(reply, 'a', "(ssbttto)");
494 HASHMAP_FOREACH(image, images, i) {
495 _cleanup_free_ char *p = NULL;
497 p = image_bus_path(image->name);
501 r = sd_bus_message_append(reply, "(ssbttto)",
503 image_type_to_string(image->type),
513 r = sd_bus_message_close_container(reply);
517 return sd_bus_send(bus, reply, NULL);
520 static int method_open_machine_pty(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
521 Manager *m = userdata;
530 r = sd_bus_message_read(message, "s", &name);
532 return sd_bus_error_set_errno(error, r);
534 machine = hashmap_get(m->machines, name);
536 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name);
538 return bus_machine_method_open_pty(bus, message, machine, error);
541 static int method_open_machine_login(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
542 Manager *m = userdata;
551 r = sd_bus_message_read(message, "s", &name);
555 machine = hashmap_get(m->machines, name);
557 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name);
559 return bus_machine_method_open_login(bus, message, machine, error);
562 static int method_bind_mount_machine(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
563 Manager *m = userdata;
572 r = sd_bus_message_read(message, "s", &name);
576 machine = hashmap_get(m->machines, name);
578 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name);
580 return bus_machine_method_bind_mount(bus, message, machine, error);
583 static int method_copy_machine(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
584 Manager *m = userdata;
593 r = sd_bus_message_read(message, "s", &name);
597 machine = hashmap_get(m->machines, name);
599 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name);
601 return bus_machine_method_copy(bus, message, machine, error);
604 static int method_remove_image(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
605 _cleanup_(image_unrefp) Image* i = NULL;
612 r = sd_bus_message_read(message, "s", &name);
616 if (!image_name_is_valid(name))
617 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Image name '%s' is invalid.", name);
619 r = image_find(name, &i);
623 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_IMAGE, "No image '%s' known", name);
625 return bus_image_method_remove(bus, message, i, error);
628 static int method_rename_image(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
629 _cleanup_(image_unrefp) Image* i = NULL;
630 const char *old_name;
636 r = sd_bus_message_read(message, "s", &old_name);
640 if (!image_name_is_valid(old_name))
641 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Image name '%s' is invalid.", old_name);
643 r = image_find(old_name, &i);
647 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_IMAGE, "No image '%s' known", old_name);
649 return bus_image_method_rename(bus, message, i, error);
652 static int method_clone_image(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
653 _cleanup_(image_unrefp) Image *i = NULL;
654 const char *old_name;
658 r = sd_bus_message_read(message, "s", &old_name);
662 if (!image_name_is_valid(old_name))
663 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Image name '%s' is invalid.", old_name);
665 r = image_find(old_name, &i);
669 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_IMAGE, "No image '%s' known", old_name);
671 return bus_image_method_clone(bus, message, i, error);
674 static int method_mark_image_read_only(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
675 _cleanup_(image_unrefp) Image *i = NULL;
680 r = sd_bus_message_read(message, "s", &name);
684 if (!image_name_is_valid(name))
685 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Image name '%s' is invalid.", name);
687 r = image_find(name, &i);
691 return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_IMAGE, "No image '%s' known", name);
693 return bus_image_method_mark_read_only(bus, message, i, error);
696 const sd_bus_vtable manager_vtable[] = {
697 SD_BUS_VTABLE_START(0),
698 SD_BUS_METHOD("GetMachine", "s", "o", method_get_machine, SD_BUS_VTABLE_UNPRIVILEGED),
699 SD_BUS_METHOD("GetImage", "s", "o", method_get_image, SD_BUS_VTABLE_UNPRIVILEGED),
700 SD_BUS_METHOD("GetMachineByPID", "u", "o", method_get_machine_by_pid, SD_BUS_VTABLE_UNPRIVILEGED),
701 SD_BUS_METHOD("ListMachines", NULL, "a(ssso)", method_list_machines, SD_BUS_VTABLE_UNPRIVILEGED),
702 SD_BUS_METHOD("ListImages", NULL, "a(ssbttto)", method_list_images, SD_BUS_VTABLE_UNPRIVILEGED),
703 SD_BUS_METHOD("CreateMachine", "sayssusa(sv)", "o", method_create_machine, 0),
704 SD_BUS_METHOD("CreateMachineWithNetwork", "sayssusaia(sv)", "o", method_create_machine_with_network, 0),
705 SD_BUS_METHOD("RegisterMachine", "sayssus", "o", method_register_machine, 0),
706 SD_BUS_METHOD("RegisterMachineWithNetwork", "sayssusai", "o", method_register_machine_with_network, 0),
707 SD_BUS_METHOD("TerminateMachine", "s", NULL, method_terminate_machine, SD_BUS_VTABLE_CAPABILITY(CAP_KILL)),
708 SD_BUS_METHOD("KillMachine", "ssi", NULL, method_kill_machine, SD_BUS_VTABLE_CAPABILITY(CAP_KILL)),
709 SD_BUS_METHOD("GetMachineAddresses", "s", "a(iay)", method_get_machine_addresses, SD_BUS_VTABLE_UNPRIVILEGED),
710 SD_BUS_METHOD("GetMachineOSRelease", "s", "a{ss}", method_get_machine_os_release, SD_BUS_VTABLE_UNPRIVILEGED),
711 SD_BUS_METHOD("OpenMachinePTY", "s", "hs", method_open_machine_pty, 0),
712 SD_BUS_METHOD("OpenMachineLogin", "s", "hs", method_open_machine_login, SD_BUS_VTABLE_UNPRIVILEGED),
713 SD_BUS_METHOD("BindMountMachine", "sssbb", NULL, method_bind_mount_machine, 0),
714 SD_BUS_METHOD("CopyFromMachine", "sss", NULL, method_copy_machine, 0),
715 SD_BUS_METHOD("CopyToMachine", "sss", NULL, method_copy_machine, 0),
716 SD_BUS_METHOD("RemoveImage", "s", NULL, method_remove_image, 0),
717 SD_BUS_METHOD("RenameImage", "ss", NULL, method_rename_image, 0),
718 SD_BUS_METHOD("CloneImage", "ssb", NULL, method_clone_image, 0),
719 SD_BUS_METHOD("MarkImageReadOnly", "sb", NULL, method_mark_image_read_only, 0),
720 SD_BUS_SIGNAL("MachineNew", "so", 0),
721 SD_BUS_SIGNAL("MachineRemoved", "so", 0),
725 int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
726 const char *path, *result, *unit;
727 Manager *m = userdata;
736 r = sd_bus_message_read(message, "uoss", &id, &path, &unit, &result);
738 bus_log_parse_error(r);
742 machine = hashmap_get(m->machine_units, unit);
746 if (streq_ptr(path, machine->scope_job)) {
747 free(machine->scope_job);
748 machine->scope_job = NULL;
750 if (machine->started) {
751 if (streq(result, "done"))
752 machine_send_create_reply(machine, NULL);
754 _cleanup_bus_error_free_ sd_bus_error e = SD_BUS_ERROR_NULL;
756 sd_bus_error_setf(&e, BUS_ERROR_JOB_FAILED, "Start job for unit %s failed with '%s'", unit, result);
758 machine_send_create_reply(machine, &e);
761 machine_save(machine);
764 machine_add_to_gc_queue(machine);
768 int match_properties_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
769 _cleanup_free_ char *unit = NULL;
770 Manager *m = userdata;
779 path = sd_bus_message_get_path(message);
783 r = unit_name_from_dbus_path(path, &unit);
784 if (r == -EINVAL) /* not for a unit */
789 machine = hashmap_get(m->machine_units, unit);
791 machine_add_to_gc_queue(machine);
796 int match_unit_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
797 const char *path, *unit;
798 Manager *m = userdata;
806 r = sd_bus_message_read(message, "so", &unit, &path);
808 bus_log_parse_error(r);
812 machine = hashmap_get(m->machine_units, unit);
814 machine_add_to_gc_queue(machine);
819 int match_reloading(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
820 Manager *m = userdata;
827 r = sd_bus_message_read(message, "b", &b);
829 bus_log_parse_error(r);
835 /* systemd finished reloading, let's recheck all our machines */
836 log_debug("System manager has been reloaded, rechecking machines...");
838 HASHMAP_FOREACH(machine, m->machines, i)
839 machine_add_to_gc_queue(machine);
844 int manager_start_scope(
849 const char *description,
850 sd_bus_message *more_properties,
854 _cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
861 r = sd_bus_message_new_method_call(
864 "org.freedesktop.systemd1",
865 "/org/freedesktop/systemd1",
866 "org.freedesktop.systemd1.Manager",
867 "StartTransientUnit");
871 r = sd_bus_message_append(m, "ss", strempty(scope), "fail");
875 r = sd_bus_message_open_container(m, 'a', "(sv)");
879 if (!isempty(slice)) {
880 r = sd_bus_message_append(m, "(sv)", "Slice", "s", slice);
885 if (!isempty(description)) {
886 r = sd_bus_message_append(m, "(sv)", "Description", "s", description);
891 r = sd_bus_message_append(m, "(sv)", "PIDs", "au", 1, pid);
895 r = sd_bus_message_append(m, "(sv)", "Delegate", "b", 1);
899 if (more_properties) {
900 r = sd_bus_message_copy(m, more_properties, true);
905 r = sd_bus_message_close_container(m);
909 r = sd_bus_message_append(m, "a(sa(sv))", 0);
913 r = sd_bus_call(manager->bus, m, 0, error, &reply);
921 r = sd_bus_message_read(reply, "o", &j);
935 int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job) {
936 _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
942 r = sd_bus_call_method(
944 "org.freedesktop.systemd1",
945 "/org/freedesktop/systemd1",
946 "org.freedesktop.systemd1.Manager",
952 if (sd_bus_error_has_name(error, BUS_ERROR_NO_SUCH_UNIT) ||
953 sd_bus_error_has_name(error, BUS_ERROR_LOAD_FAILED)) {
958 sd_bus_error_free(error);
969 r = sd_bus_message_read(reply, "o", &j);
983 int manager_kill_unit(Manager *manager, const char *unit, int signo, sd_bus_error *error) {
987 return sd_bus_call_method(
989 "org.freedesktop.systemd1",
990 "/org/freedesktop/systemd1",
991 "org.freedesktop.systemd1.Manager",
995 "ssi", unit, "all", signo);
998 int manager_unit_is_active(Manager *manager, const char *unit) {
999 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
1000 _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
1001 _cleanup_free_ char *path = NULL;
1008 path = unit_dbus_path_from_name(unit);
1012 r = sd_bus_get_property(
1014 "org.freedesktop.systemd1",
1016 "org.freedesktop.systemd1.Unit",
1022 if (sd_bus_error_has_name(&error, SD_BUS_ERROR_NO_REPLY) ||
1023 sd_bus_error_has_name(&error, SD_BUS_ERROR_DISCONNECTED))
1026 if (sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_UNIT) ||
1027 sd_bus_error_has_name(&error, BUS_ERROR_LOAD_FAILED))
1033 r = sd_bus_message_read(reply, "s", &state);
1037 return !streq(state, "inactive") && !streq(state, "failed");
1040 int manager_job_is_active(Manager *manager, const char *path) {
1041 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
1042 _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
1048 r = sd_bus_get_property(
1050 "org.freedesktop.systemd1",
1052 "org.freedesktop.systemd1.Job",
1058 if (sd_bus_error_has_name(&error, SD_BUS_ERROR_NO_REPLY) ||
1059 sd_bus_error_has_name(&error, SD_BUS_ERROR_DISCONNECTED))
1062 if (sd_bus_error_has_name(&error, SD_BUS_ERROR_UNKNOWN_OBJECT))
1068 /* We don't actually care about the state really. The fact
1069 * that we could read the job state is enough for us */
1074 int manager_get_machine_by_pid(Manager *m, pid_t pid, Machine **machine) {
1075 _cleanup_free_ char *unit = NULL;
1083 r = cg_pid_get_unit(pid, &unit);
1085 mm = hashmap_get(m->machine_leaders, UINT_TO_PTR(pid));
1087 mm = hashmap_get(m->machine_units, unit);
1096 int manager_add_machine(Manager *m, const char *name, Machine **_machine) {
1102 machine = hashmap_get(m->machines, name);
1104 machine = machine_new(m, name);
1110 *_machine = machine;