[systemd-commits] 3 commits - src/core TODO

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Thu Feb 26 06:42:38 PST 2015


 TODO                    |    3 +++
 src/core/dbus-manager.c |   20 +++++++++++++++++++-
 src/core/dbus-manager.h |    1 +
 src/core/manager.c      |   17 +++++++++++++++++
 src/core/manager.h      |    2 ++
 src/core/unit.c         |   11 +++++------
 6 files changed, 47 insertions(+), 7 deletions(-)

New commits:
commit 03455c2879699852b691903343e378c28992ff6a
Author: Lucas De Marchi <lucas.demarchi at intel.com>
Date:   Wed Feb 18 14:22:37 2015 -0200

    core: emit changes for NFailedUnits property
    
    By notifying the clients when this property is changed it's possible to
    allow "system health monitor" tools to get transitions like
    running<->degraded. This is an alternative to send changes on the
    SystemState property since the latter is more difficult to derive.

diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index c8937ee..feca6e8 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -1985,7 +1985,7 @@ const sd_bus_vtable bus_manager_vtable[] = {
         SD_BUS_WRITABLE_PROPERTY("LogLevel", "s", property_get_log_level, property_set_log_level, 0, 0),
         SD_BUS_WRITABLE_PROPERTY("LogTarget", "s", property_get_log_target, property_set_log_target, 0, 0),
         SD_BUS_PROPERTY("NNames", "u", property_get_n_names, 0, 0),
-        SD_BUS_PROPERTY("NFailedUnits", "u", property_get_n_failed_units, 0, 0),
+        SD_BUS_PROPERTY("NFailedUnits", "u", property_get_n_failed_units, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
         SD_BUS_PROPERTY("NJobs", "u", property_get_n_jobs, 0, 0),
         SD_BUS_PROPERTY("NInstalledJobs", "u", bus_property_get_unsigned, offsetof(Manager, n_installed_jobs), 0),
         SD_BUS_PROPERTY("NFailedJobs", "u", bus_property_get_unsigned, offsetof(Manager, n_failed_jobs), 0),
@@ -2138,5 +2138,23 @@ void bus_manager_send_reloading(Manager *m, bool active) {
         r = bus_foreach_bus(m, NULL, send_reloading, INT_TO_PTR(active));
         if (r < 0)
                 log_debug_errno(r, "Failed to send reloading signal: %m");
+}
+
+static int send_changed_signal(sd_bus *bus, void *userdata) {
+        assert(bus);
+
+        return sd_bus_emit_properties_changed_strv(bus,
+                                                   "/org/freedesktop/systemd1",
+                                                   "org.freedesktop.systemd1.Manager",
+                                                   NULL);
+}
 
+void bus_manager_send_change_signal(Manager *m) {
+        int r;
+
+        assert(m);
+
+        r = bus_foreach_bus(m, NULL, send_changed_signal, NULL);
+        if (r < 0)
+                log_debug_errno(r, "Failed to send manager change signal: %m");
 }
diff --git a/src/core/dbus-manager.h b/src/core/dbus-manager.h
index 3730deb..5bdf6e1 100644
--- a/src/core/dbus-manager.h
+++ b/src/core/dbus-manager.h
@@ -27,3 +27,4 @@ extern const sd_bus_vtable bus_manager_vtable[];
 
 void bus_manager_send_finished(Manager *m, usec_t firmware_usec, usec_t loader_usec, usec_t kernel_usec, usec_t initrd_usec, usec_t userspace_usec, usec_t total_usec);
 void bus_manager_send_reloading(Manager *m, bool active);
+void bus_manager_send_change_signal(Manager *m);
diff --git a/src/core/manager.c b/src/core/manager.c
index 79a9d54..7966b38 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -3053,6 +3053,23 @@ const char *manager_get_runtime_prefix(Manager *m) {
                getenv("XDG_RUNTIME_DIR");
 }
 
+void manager_update_failed_units(Manager *m, Unit *u, bool failed) {
+        unsigned size;
+
+        assert(m);
+        assert(u->manager == m);
+
+        size = set_size(m->failed_units);
+
+        if (failed)
+                set_put(m->failed_units, u);
+        else
+                set_remove(m->failed_units, u);
+
+        if (set_size(m->failed_units) != size)
+                bus_manager_send_change_signal(m);
+}
+
 ManagerState manager_state(Manager *m) {
         Unit *u;
 
diff --git a/src/core/manager.h b/src/core/manager.h
index 4e33ba6..a1caab4 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -362,5 +362,7 @@ const char *manager_get_runtime_prefix(Manager *m);
 
 ManagerState manager_state(Manager *m);
 
+void manager_update_failed_units(Manager *m, Unit *u, bool failed);
+
 const char *manager_state_to_string(ManagerState m) _const_;
 ManagerState manager_state_from_string(const char *s) _pure_;
diff --git a/src/core/unit.c b/src/core/unit.c
index 590ca35..63ccd67 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -516,7 +516,7 @@ void unit_free(Unit *u) {
                 free(u->cgroup_path);
         }
 
-        set_remove(u->manager->failed_units, u);
+        manager_update_failed_units(u->manager, u, false);
         set_remove(u->manager->startup_units, u);
 
         free(u->description);
@@ -1797,10 +1797,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
         }
 
         /* Keep track of failed units */
-        if (ns == UNIT_FAILED)
-                set_put(u->manager->failed_units, u);
-        else
-                set_remove(u->manager->failed_units, u);
+        manager_update_failed_units(u->manager, u, ns == UNIT_FAILED);
 
         /* Make sure the cgroup is always removed when we become inactive */
         if (UNIT_IS_INACTIVE_OR_FAILED(ns))

commit e342b74468870f2e4f3e15f7277a0adea42183ca
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Thu Feb 26 09:27:12 2015 -0500

    Update TODO

diff --git a/TODO b/TODO
index ca91b12..e8e4800 100644
--- a/TODO
+++ b/TODO
@@ -34,6 +34,9 @@ External:
 
 Features:
 
+* When logging about multiple units (stopping BoundTo units, conflicts, etc.),
+  log both units as UNIT=, so that journalctl -u triggers on both.
+
 * to allow "linking" of nspawn containers, extend --network-bridge= so
   that it can dynamically create bridge interfaces that are refcounted
   by the containers on them. For each group of containers to link together

commit 98f738b62047229af4a929d7996e2ab04253b02c
Author: Colin Walters <walters at verbum.org>
Date:   Tue Feb 17 13:47:34 2015 -0500

    unit: When stopping due to BindsTo=, log which unit caused it
    
    I'm trying to track down a relatively recent change in systemd
    which broke OSTree; see https://bugzilla.gnome.org/show_bug.cgi?id=743891
    
    Systemd started to stop sysroot.mount, and this patch should help
    me debug why at least.
    
    While we're here, "break" on the first unit we find that will
    deactivate, as there's no point in further iteration.

diff --git a/src/core/unit.c b/src/core/unit.c
index 875befa..590ca35 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1642,12 +1642,14 @@ static void unit_check_binds_to(Unit *u) {
                         continue;
 
                 stop = true;
+                break;
         }
 
         if (!stop)
                 return;
 
-        log_unit_info(u->id, "Unit %s is bound to inactive unit. Stopping, too.", u->id);
+        assert(other);
+        log_unit_info(u->id, "Unit %s is bound to inactive unit %s. Stopping, too.", u->id, other->id);
 
         /* A unit we need to run is gone. Sniff. Let's stop this. */
         manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, true, NULL, NULL);



More information about the systemd-commits mailing list