summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-core/systemd
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-core/systemd')
-rw-r--r--meta-openbmc-mods/meta-common/recipes-core/systemd/obmc-targets.bbappend10
-rw-r--r--meta-openbmc-mods/meta-common/recipes-core/systemd/systemd-conf/journald.conf42
-rw-r--r--meta-openbmc-mods/meta-common/recipes-core/systemd/systemd-conf/systemd-timesyncd-save-time.conf2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-core/systemd/systemd-conf_%.bbappend11
-rw-r--r--meta-openbmc-mods/meta-common/recipes-core/systemd/systemd/0001-Modfiy-system.conf-DefaultTimeoutStopSec.patch28
-rw-r--r--meta-openbmc-mods/meta-common/recipes-core/systemd/systemd/0002-Add-event-log-for-system-time-synchronization.patch114
-rw-r--r--meta-openbmc-mods/meta-common/recipes-core/systemd/systemd/systemd-time-wait-sync.service36
-rw-r--r--meta-openbmc-mods/meta-common/recipes-core/systemd/systemd_%.bbappend20
8 files changed, 263 insertions, 0 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-core/systemd/obmc-targets.bbappend b/meta-openbmc-mods/meta-common/recipes-core/systemd/obmc-targets.bbappend
new file mode 100644
index 000000000..adbdb0e6e
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-core/systemd/obmc-targets.bbappend
@@ -0,0 +1,10 @@
+# Remove these files since they are provided by obmc-intel-targets
+SYSTEMD_SERVICE:${PN}:remove += " obmc-host-start@.target"
+SYSTEMD_SERVICE:${PN}:remove += " obmc-host-stop@.target"
+SYSTEMD_SERVICE:${PN}:remove += " obmc-host-shutdown@.target"
+SYSTEMD_SERVICE:${PN}:remove += " obmc-host-reboot@.target"
+SYSTEMD_SERVICE:${PN}:remove += " obmc-host-startmin@.target"
+SYSTEMD_SERVICE:${PN}:remove += " obmc-chassis-poweron@.target"
+SYSTEMD_SERVICE:${PN}:remove += " obmc-chassis-poweroff@.target"
+SYSTEMD_SERVICE:${PN}:remove += " obmc-chassis-hard-poweroff@.target"
+SYSTEMD_SERVICE:${PN}:remove += " obmc-chassis-powerreset@.target"
diff --git a/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd-conf/journald.conf b/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd-conf/journald.conf
new file mode 100644
index 000000000..48c60d36b
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd-conf/journald.conf
@@ -0,0 +1,42 @@
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# Entries in this file show the compile time defaults.
+# You can change settings by editing this file.
+# Defaults can be restored by simply deleting this file.
+#
+# See journald.conf(5) for details.
+
+[Journal]
+Storage=volatile
+#Compress=yes
+#Seal=yes
+#SplitMode=uid
+#SyncIntervalSec=5m
+#RateLimitIntervalSec=30s
+#RateLimitBurst=10000
+#SystemMaxUse=6M
+#SystemKeepFree=
+#SystemMaxFileSize=512K
+#SystemMaxFiles=32
+RuntimeMaxUse=32M
+#RuntimeKeepFree=
+#RuntimeMaxFileSize=
+#RuntimeMaxFiles=4
+#MaxRetentionSec=
+#MaxFileSec=1month
+#ForwardToSyslog=no
+#ForwardToKMsg=no
+#ForwardToConsole=no
+#ForwardToWall=yes
+#TTYPath=/dev/console
+#MaxLevelStore=notice
+#MaxLevelSyslog=debug
+#MaxLevelKMsg=notice
+#MaxLevelConsole=info
+#MaxLevelWall=emerg
+#LineMax=48K
diff --git a/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd-conf/systemd-timesyncd-save-time.conf b/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd-conf/systemd-timesyncd-save-time.conf
new file mode 100644
index 000000000..aa455cbcb
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd-conf/systemd-timesyncd-save-time.conf
@@ -0,0 +1,2 @@
+[Service]
+ExecStop=touch /var/lib/systemd/timesync/clock \ No newline at end of file
diff --git a/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd-conf_%.bbappend b/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd-conf_%.bbappend
new file mode 100644
index 000000000..b7bd6796c
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd-conf_%.bbappend
@@ -0,0 +1,11 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+
+SRC_URI += "file://journald.conf \
+ file://systemd-timesyncd-save-time.conf \
+ "
+
+FILES:${PN} += " ${systemd_system_unitdir}/systemd-timesyncd.service.d/systemd-timesyncd-save-time.conf"
+
+do_install:append() {
+ install -m 644 -D ${WORKDIR}/systemd-timesyncd-save-time.conf ${D}${systemd_system_unitdir}/systemd-timesyncd.service.d/systemd-timesyncd-save-time.conf
+}
diff --git a/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd/0001-Modfiy-system.conf-DefaultTimeoutStopSec.patch b/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd/0001-Modfiy-system.conf-DefaultTimeoutStopSec.patch
new file mode 100644
index 000000000..5b9f17006
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd/0001-Modfiy-system.conf-DefaultTimeoutStopSec.patch
@@ -0,0 +1,28 @@
+From e02932693f92d6230b5520f431e127f7b6e2183e Mon Sep 17 00:00:00 2001
+From: James Feist <james.feist@linux.intel.com>
+Date: Tue, 6 Mar 2018 16:06:33 -0800
+Subject: [PATCH 1/1] Modfiy system.conf DefaultTimeoutStopSec
+
+Current time is 5 minutes, change it to 10 seconds.
+
+Signed-off-by: James Feist <james.feist@linux.intel.com>
+---
+ src/core/system.conf.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/core/system.conf.in b/src/core/system.conf.in
+index 8112125468..f7a35a56bb 100644
+--- a/src/core/system.conf.in
++++ b/src/core/system.conf.in
+@@ -39,7 +39,7 @@
+ #DefaultStandardOutput=journal
+ #DefaultStandardError=inherit
+ #DefaultTimeoutStartSec=90s
+-#DefaultTimeoutStopSec=90s
++DefaultTimeoutStopSec=10s
+ #DefaultTimeoutAbortSec=
+ #DefaultRestartSec=100ms
+ #DefaultStartLimitIntervalSec=10s
+--
+2.17.1
+
diff --git a/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd/0002-Add-event-log-for-system-time-synchronization.patch b/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd/0002-Add-event-log-for-system-time-synchronization.patch
new file mode 100644
index 000000000..8e07ad56a
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd/0002-Add-event-log-for-system-time-synchronization.patch
@@ -0,0 +1,114 @@
+From 5be7b53e598faa7605add3f9856d3b3eb4b50fe1 Mon Sep 17 00:00:00 2001
+From: Joshi-Mansi <mansi.joshi@linux.intel.com>
+Date: Thu, 13 May 2021 03:09:24 +0530
+Subject: [PATCH] Add event log for time synchronization
+
+Adding time synchronization event logs can be helpful in distinguishing
+older date and newly synced date with the first initialization
+(from 1970) or any later syncs either done via NTP or Manually.
+
+Tested:
+Confirmed that the event is getting logged correctly in Redfish.
+
+Signed-off-by: Joshi-Mansi <mansi.joshi@linux.intel.com>
+Change-Id: I8901227990ee7bc41de30af13c775cc45016a626
+---
+ src/timedate/timedated.c | 14 ++++++++++++++
+ src/timesync/timesyncd-manager.c | 14 ++++++++++++++
+ 2 files changed, 28 insertions(+)
+
+diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
+index 8149facb34..5da7158c0d 100644
+--- a/src/timedate/timedated.c
++++ b/src/timedate/timedated.c
+@@ -8,6 +8,7 @@
+ #include "sd-bus.h"
+ #include "sd-event.h"
+ #include "sd-messages.h"
++#include "sd-journal.h"
+
+ #include "alloc-util.h"
+ #include "bus-common-errors.h"
+@@ -805,6 +806,8 @@ static int method_set_time(sd_bus_message *m, void *userdata, sd_bus_error *erro
+ struct timespec ts;
+ usec_t start;
+ struct tm tm;
++ char olddate[FORMAT_TIMESTAMP_MAX];
++ char newdate[FORMAT_TIMESTAMP_MAX];
+
+ assert(m);
+ assert(c);
+@@ -819,6 +822,9 @@ static int method_set_time(sd_bus_message *m, void *userdata, sd_bus_error *erro
+ if (context_ntp_service_is_active(c) > 0)
+ return sd_bus_error_set(error, BUS_ERROR_AUTOMATIC_TIME_SYNC_ENABLED, "Automatic time synchronization is enabled");
+
++ usec_t oldtime = now(CLOCK_REALTIME);
++ format_timestamp(olddate, sizeof(olddate), oldtime);
++
+ /* this only gets used if dbus does not provide a timestamp */
+ start = now(CLOCK_MONOTONIC);
+
+@@ -886,6 +892,14 @@ static int method_set_time(sd_bus_message *m, void *userdata, sd_bus_error *erro
+ "REALTIME="USEC_FMT, timespec_load(&ts),
+ LOG_MESSAGE("Changed local time to %s", ctime(&ts.tv_sec)));
+
++ // Log an event when the system time is set manually
++ usec_t newtime = now(CLOCK_REALTIME);
++ format_timestamp(newdate, sizeof(newdate), newtime);
++ sd_journal_send("MESSAGE=BMC time updated Manually: New time=%s, Old time=%s",
++ newdate, olddate, "PRIORITY=%i", LOG_INFO,
++ "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.BMCTimeUpdatedManually",
++ "REDFISH_MESSAGE_ARGS=%s,%s", newdate, olddate, NULL);
++
+ return sd_bus_reply_method_return(m, NULL);
+ }
+
+diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
+index 93ba4ef87d..d46097da07 100644
+--- a/src/timesync/timesyncd-manager.c
++++ b/src/timesync/timesyncd-manager.c
+@@ -11,6 +11,7 @@
+ #include <sys/types.h>
+
+ #include "sd-daemon.h"
++#include "sd-journal.h"
+
+ #include "alloc-util.h"
+ #include "dns-domain.h"
+@@ -425,6 +426,8 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
+ bool spike;
+ int leap_sec;
+ int r;
++ char olddate[FORMAT_TIMESTAMP_MAX];
++ char newdate[FORMAT_TIMESTAMP_MAX];
+
+ assert(source);
+ assert(m);
+@@ -513,6 +516,9 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
+ return manager_connect(m);
+ }
+
++ usec_t oldtime = now(CLOCK_REALTIME);
++ format_timestamp(olddate, sizeof(olddate), oldtime);
++
+ /* valid packet */
+ m->pending = false;
+ m->retry_interval = 0;
+@@ -610,6 +616,14 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
+
+ server_address_pretty(m->current_server_address, &pretty);
+ /* "Initial", as further successful syncs will not be logged. */
++ /* Log an event for NTP Synchronization from older date to newly synced date. */
++ usec_t newtime = now(CLOCK_REALTIME);
++ format_timestamp(newdate, sizeof(newdate), newtime);
++ sd_journal_send("MESSAGE=BMC time updated via NTP: New time=%s, Old time=%s",
++ newdate, olddate, "PRIORITY=%i", LOG_INFO,
++ "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.BMCTimeUpdatedViaNTP",
++ "REDFISH_MESSAGE_ARGS=%s,%s", newdate, olddate, NULL);
++
+ log_info("Initial synchronization to time server %s (%s).", strna(pretty), m->current_server_name->string);
+ sd_notifyf(false, "STATUS=Initial synchronization to time server %s (%s).", strna(pretty), m->current_server_name->string);
+ }
+--
+2.17.1
+
diff --git a/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd/systemd-time-wait-sync.service b/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd/systemd-time-wait-sync.service
new file mode 100644
index 000000000..f71aea39d
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd/systemd-time-wait-sync.service
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: LGPL-2.1+
+#
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Wait Until Kernel Time Synchronized
+Documentation=man:systemd-time-wait-sync.service(8)
+
+# Note that this tool doesn't need CAP_SYS_TIME itself, but it's primary
+# usecase is to run in conjunction with a local NTP service such as
+# systemd-timesyncd.service, which is conditioned this way. There might be
+# niche usecases where running this service independently is desired, but let's
+# make this all "just work" for the general case, and leave it to local
+# modifications to make it work in the remaining cases.
+
+ConditionCapability=CAP_SYS_TIME
+ConditionVirtualization=!container
+
+DefaultDependencies=no
+Before=time-sync.target shutdown.target
+Wants=time-sync.target
+Conflicts=shutdown.target
+
+[Service]
+Type=oneshot
+ExecStart=/lib/systemd/systemd-time-wait-sync
+TimeoutStartSec=10
+RemainAfterExit=yes
+
+[Install]
+WantedBy=sysinit.target
diff --git a/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd_%.bbappend b/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd_%.bbappend
new file mode 100644
index 000000000..50f82d21e
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-core/systemd/systemd_%.bbappend
@@ -0,0 +1,20 @@
+# add some configuration overrides for systemd defaults
+
+LICENSE = "GPL-2.0"
+
+FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+
+SRC_URI += "file://0001-Modfiy-system.conf-DefaultTimeoutStopSec.patch \
+ file://systemd-time-wait-sync.service \
+ file://0002-Add-event-log-for-system-time-synchronization.patch \
+ "
+
+USERADD_PACKAGES:remove = "${PN}-journal-gateway ${PN}-journal-upload ${PN}-journal-remote"
+
+do_install:append(){
+ rm -rf ${D}/lib/udev/rules.d/80-drivers.rules
+ cp -f ${WORKDIR}/systemd-time-wait-sync.service ${D}/lib/systemd/system/
+}
+
+PACKAGECONFIG:remove = " kmod"
+PACKAGECONFIG:append = " logind"