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

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Tue Jul 2 21:35:53 PDT 2013


On Wed, Jun 26, 2013 at 03:06:38PM +0200, harald at redhat.com wrote:
> From: Harald Hoyer <harald at redhat.com>
> 
> $ systemctl status dracut-initqueue.service
> dracut-initqueue.service - dracut initqueue hook
>    Loaded: loaded (/usr/lib/systemd/system/dracut-initqueue.service;
> static)
>    Active: inactive (dead)
>           start condition failed at Wed 2013-06-26 13:01:05 UTC; 22s ago
>      Docs: man:dracut-initqueue.service(8)
> 
> Jun 26 13:01:05 lenovo systemd[1]: Starting of dracut-initqueue.service
> skipped because the following start conditions were not met:
>    ConditionKernelCommandLine:|rd.break=initqueue
>    ConditionPathExistsGlob: |/lib/dracut/hooks/initqueue/timeout/*.sh
>    ConditionPathExistsGlob: |/lib/dracut/hooks/initqueue/online/*.sh
>    ConditionPathExistsGlob: |/lib/dracut/hooks/initqueue/finished/*.sh
>    ConditionPathExistsGlob: |/lib/dracut/hooks/initqueue/settled/*.sh
>    ConditionPathExistsGlob: |/lib/dracut/hooks/initqueue/*.sh
>    ConditionPathExists: |/lib/dracut/need-initqueue
Hi Harald,

your patch seems to is better than mine, I somehow missed
the question of muliple conditions. I think you should go ahead
and appy this.

My patch also exported the failing condition over dbus. I guess
we might still want to do this, but let's get this basic functionality
in first.

> +                if (!(f = open_memstream(&buf, &size))) {
Style:
	        f = open_memstream(&buf, &size);
                if (!f) {

> +                        log_warning("Failed to allocate memory stream.");
> +                        return -EALREADY;
> +                }
> +
> +                condition_dump_list_result(u->conditions, f);
> +
> +                if (ferror(f)) {
> +                        fclose(f);
> +                        log_warning("Failed to write status stream");
> +                        return -EALREADY;
> +                }
> +
> +                fclose(f);
> +
> +                log_struct_unit(LOG_NOTICE,
> +                           u->id,
> +                           MESSAGE_ID(SD_MESSAGE_UNIT_CONDITIONS),
> +                           "MESSAGE=Starting of %s skipped because the following start conditions were not met:\n%s", u->id, buf,
> +                           "CONDITION_RESULTS=%s", buf,
> +                           NULL);
> +
>                  return -EALREADY;
>          }
>  
> diff --git a/src/systemd/sd-messages.h b/src/systemd/sd-messages.h
> index c811a06..c85dda1 100644
> --- a/src/systemd/sd-messages.h
> +++ b/src/systemd/sd-messages.h
> @@ -62,6 +62,7 @@ extern "C" {
>  
>  #define SD_MESSAGE_UNIT_STARTING    SD_ID128_MAKE(7d,49,58,e8,42,da,4a,75,8f,6c,1c,dc,7b,36,dc,c5)
>  #define SD_MESSAGE_UNIT_STARTED     SD_ID128_MAKE(39,f5,34,79,d3,a0,45,ac,8e,11,78,62,48,23,1f,bf)
> +#define SD_MESSAGE_UNIT_CONDITIONS     SD_ID128_MAKE(b1,44,ed,c7,3c,f3,49,3b,b4,44,2c,67,03,61,ea,e8)
Strange indentation...

>  #define SD_MESSAGE_UNIT_STOPPING    SD_ID128_MAKE(de,5b,42,6a,63,be,47,a7,b6,ac,3e,aa,c8,2e,2f,6f)
>  #define SD_MESSAGE_UNIT_STOPPED     SD_ID128_MAKE(9d,1a,aa,27,d6,01,40,bd,96,36,54,38,aa,d2,02,86)
>  #define SD_MESSAGE_UNIT_FAILED      SD_ID128_MAKE(be,02,cf,68,55,d2,42,8b,a4,0d,f7,e9,d0,22,f0,3d)

Zbyszek


More information about the systemd-devel mailing list