[systemd-devel] [PATCH] Log failing start conditions

Lennart Poettering lennart at poettering.net
Thu Jul 18 05:47:56 PDT 2013

On Thu, 18.07.13 05:52, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:

> > I'd prefer if we'd solve this without the journal. Instead, I think
> > "struct Condition" should be extended to store the most recent test
> > result in a tri-state, i.e. negative for "untested", zero for "failed",
> > positive for "succeeded". Then we should add bus property to the Unit
> > interface that is an array of structs with the conditions in them,
> > including their results.

> I've now extended the dbus api, except that 0 means untested,
> >0 means OK, <0 means failed, in case we decide to extend failed 
> later on.

Hmm, so thinking about this, it probably is not a good idea to expose a
tristate as an int on the bus, but do that the same way as we expose
enums (i.e. as strings).

We already have some generic support for tri-states in place. For
example, there is config_parse_tristate() which parses a configuration
boolean into a tri-state int. And we have
bus_property_append_tristate_false() which serializes a tri-state int to
a dbus boolean mapping both < 0 and 0 to false.

Now, in both cases the externally visible type is actually a bool, even
if we internally distuingish three different states. For the condition
stuff it is necessary to *actually* distuingish three states on the wire
too. D-Bus doesn't know this natively however.

Maybe use a string and map > 0 to "t", 0 to "f" and < 0 to ""?

static inline const char* tristate_to_string(int v) {
       return v > 0 ? "t" : 
             v == 0 ? "f" : "";

Or something like that?

Sounds a bit more future proof that way I think. 

What I am afraid of here is that if we expose tristate-as-int on the bus
that people will actually assume -1 and 1 are the values to check for,
even though we actually mean < 0 and > 0...

> > With that in place systemctl should simple retrieve this property and
> > show the results of *all* individual condition checks if the overall
> > condition result was negatzive.
> systemctl now will add a line (at most one), describing which condition
> or condtions failed. Full output like in Harald's patch is not shown,
> although we could still add it without any trouble, because full information
> is exported over dbus. Nevertheless, I think current output is fine.

Great work! Thanks!


Lennart Poettering - Red Hat, Inc.

More information about the systemd-devel mailing list