mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
do not report total time when kernel time is not provided (#8063)
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
This commit is contained in:
parent
a1db49c30e
commit
d21b0c826f
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user