]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
do not report total time when kernel time is not provided (#8063)
authorBoucman <jeremy.rosen@enst-bretagne.fr>
Fri, 2 Feb 2018 14:58:40 +0000 (15:58 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 2 Feb 2018 14:58:40 +0000 (15:58 +0100)
the whole systemd-analyze time logic is based on the fact that monotonic
time 0 is the start of the kernel.

If the firmware does not provide a correct time, firmware_time degrades to
0, which is the start of the kernel. The diference between FinishTime and
firmware_time is thus correct.

That assumption is still true with containers, but the start time of the
kernel is not what the user expects : It's the time when the host booted.

The total is thus still correct, but highly misleading. Containers can be
easily detected (and, in fact, already are) by systemd not reporting any
kernel non-monotonic timestamp.

This patch simply avoids printing a misleading time when it can detect that
case

src/analyze/analyze.c

index 834620a4cd7d2e9a84468c1abe2a49c80cdf91d0..aab61e4de3b3a55849ecf141d2402095d76fb9f0 100644 (file)
@@ -547,7 +547,8 @@ static int pretty_boot_time(sd_bus *bus, char **_buf) {
                 size = strpcpyf(&ptr, size, "%s (initrd) + ", format_timespan(ts, sizeof(ts), t->userspace_time - t->initrd_time, USEC_PER_MSEC));
 
         size = strpcpyf(&ptr, size, "%s (userspace) ", format_timespan(ts, sizeof(ts), t->finish_time - t->userspace_time, USEC_PER_MSEC));
-        strpcpyf(&ptr, size, "= %s", format_timespan(ts, sizeof(ts), t->firmware_time + t->finish_time, USEC_PER_MSEC));
+        if (t->kernel_time > 0)
+                strpcpyf(&ptr, size, "= %s", format_timespan(ts, sizeof(ts), t->firmware_time + t->finish_time, USEC_PER_MSEC));
 
         if (unit_id && (activated_time > 0 && activated_time != USEC_INFINITY))
                 size = strpcpyf(&ptr, size, "\n%s reached after %s in userspace", unit_id, format_timespan(ts, sizeof(ts), activated_time - t->userspace_time, USEC_PER_MSEC));