[systemd-devel] [PATCH v4] bus-util: be more verbose if dbus job fails

Dave Reisner d at falconindy.com
Fri Apr 10 06:24:48 PDT 2015


On Fri, Apr 10, 2015 at 01:48:42PM +0200, Michal Sekletar wrote:
> Users might have hard time figuring out why exactly their systemctl request
> failed. If dbus job fails try to figure out more details about failure by
> examining Result property of the service.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1016680
> ---
> 
> Changes in v4:
>         - log function moved to bus-util.c
>         - used strna around service_shell_quoted
> 
>  src/libsystemd/sd-bus/bus-util.c | 84 ++++++++++++++++++++++++++++++++++++----
>  1 file changed, 77 insertions(+), 7 deletions(-)
> 
> diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
> index ea2379d..553c62b 100644
> --- a/src/libsystemd/sd-bus/bus-util.c
> +++ b/src/libsystemd/sd-bus/bus-util.c
> @@ -30,6 +30,7 @@
>  #include "path-util.h"
>  #include "missing.h"
>  #include "set.h"
> +#include "unit-name.h"
>  
>  #include "sd-bus.h"
>  #include "bus-error.h"
> @@ -1708,6 +1709,73 @@ static int bus_process_wait(sd_bus *bus) {
>          }
>  }
>  
> +static int bus_job_get_service_result(BusWaitForJobs *d, char **result) {
> +        int r = 0;
> +        _cleanup_free_ char *dbus_path = NULL, *p = NULL;
> +
> +        assert(d);
> +        assert(d->name);
> +        assert(result);
> +
> +        dbus_path = unit_dbus_path_from_name(d->name);
> +        if (!dbus_path)
> +                return -ENOMEM;
> +
> +        r = sd_bus_get_property_string(d->bus,
> +                                       "org.freedesktop.systemd1",
> +                                       dbus_path,
> +                                       "org.freedesktop.systemd1.Service",
> +                                       "Result",
> +                                       NULL,
> +                                       &p);
> +        if (r < 0)
> +                return r;
> +
> +        *result = p;
> +        p = NULL;
> +
> +        return 0;
> +}
> +
> +static const struct {
> +        const char *result, *explanation;
> +} explanations [] = {
> +        { "resources", "configured resource limit was exceeded" },
> +        { "timeout", "timeout was exceeded" },
> +        { "exit-code", "control process exited with error code" },
> +        { "signal", "fatal signal was delivered to the control process" },
> +        { "core-dump", "fatal signal was delivered to the control process. Core dumped" },
> +        { "watchdog", "service failed to sent watchdog ping" },

s/sent/send/



More information about the systemd-devel mailing list