#include "bus-util.h"
#include "bus-error.h"
#include "machined.h"
+#include "label.h"
Manager *manager_new(void) {
Manager *m;
if (!m)
return NULL;
- m->machines = hashmap_new(string_hash_func, string_compare_func);
- m->machine_units = hashmap_new(string_hash_func, string_compare_func);
- m->machine_leaders = hashmap_new(trivial_hash_func, trivial_compare_func);
+ m->machines = hashmap_new(&string_hash_ops);
+ m->machine_units = hashmap_new(&string_hash_ops);
+ m->machine_leaders = hashmap_new(NULL);
if (!m->machines || !m->machine_units || !m->machine_leaders) {
manager_free(m);
k = manager_add_machine(m, de->d_name, &machine);
if (k < 0) {
- log_error("Failed to add machine by file name %s: %s", de->d_name, strerror(-k));
+ log_error_errno(-k, "Failed to add machine by file name %s: %m", de->d_name);
r = k;
continue;
r = sd_bus_default_system(&m->bus);
if (r < 0) {
- log_error("Failed to connect to system bus: %s", strerror(-r));
+ log_error_errno(-r, "Failed to connect to system bus: %m");
return r;
}
r = sd_bus_add_object_vtable(m->bus, NULL, "/org/freedesktop/machine1", "org.freedesktop.machine1.Manager", manager_vtable, m);
if (r < 0) {
- log_error("Failed to add manager object vtable: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add manager object vtable: %m");
return r;
}
r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/machine1/machine", "org.freedesktop.machine1.Machine", machine_vtable, machine_object_find, m);
if (r < 0) {
- log_error("Failed to add machine object vtable: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add machine object vtable: %m");
return r;
}
r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/machine1/machine", machine_node_enumerator, m);
if (r < 0) {
- log_error("Failed to add machine enumerator: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add machine enumerator: %m");
return r;
}
match_job_removed,
m);
if (r < 0) {
- log_error("Failed to add match for JobRemoved: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for JobRemoved: %m");
return r;
}
match_unit_removed,
m);
if (r < 0) {
- log_error("Failed to add match for UnitRemoved: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for UnitRemoved: %m");
return r;
}
match_properties_changed,
m);
if (r < 0) {
- log_error("Failed to add match for PropertiesChanged: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for PropertiesChanged: %m");
return r;
}
match_reloading,
m);
if (r < 0) {
- log_error("Failed to add match for Reloading: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match for Reloading: %m");
return r;
}
r = sd_bus_request_name(m->bus, "org.freedesktop.machine1", 0);
if (r < 0) {
- log_error("Failed to register name: %s", strerror(-r));
+ log_error_errno(-r, "Failed to register name: %m");
return r;
}
r = sd_bus_attach_event(m->bus, m->event, 0);
if (r < 0) {
- log_error("Failed to attach bus to event loop: %s", strerror(-r));
+ log_error_errno(-r, "Failed to attach bus to event loop: %m");
return r;
}
r = manager_startup(m);
if (r < 0) {
- log_error("Failed to fully start up daemon: %s", strerror(-r));
+ log_error_errno(-r, "Failed to fully start up daemon: %m");
goto finish;
}
log_debug("systemd-machined stopped as pid "PID_FMT, getpid());
finish:
- sd_notify(false,
- "STOPPING=1\n"
- "STATUS=Shutting down...");
-
if (m)
manager_free(m);