Re: [isar-cip-core] swupdate: add recipe to cause kernel panic during system boot


Jan Kiszka
 

On 27.01.22 15:20, Shivanand.Kunijadar@... wrote:
From: Shivanand Kunijadar <Shivanand.Kunijadar@...>
Cc: dinesh.kumar@...,
kazuhiro3.hayashi@...,
akihiro27.suzuki@...
This recipe adds necessary scripts to cause kernel panic during system
boot, these scripts are required to test swupdate rollback feature.
Valuable piece in the puzzle! I would just use a different name than "swupdate-rollback". Effectively, this creates a broken boot, not only for swupdate, no? Then call it accordingly.

The fact that a broken boot will trigger a rollback under swupdate is a consequence, but not directly related to these changes.

Signed-off-by: Shivanand Kunijadar <Shivanand.Kunijadar@...>
---
kas/opt/swupdate-rollback.yml | 19 +++++++++++++
.../files/sysrq-panic.service | 10 +++++++
.../swupdate-rollback/files/sysrq-panic.sh | 4 +++
.../swupdate-rollback/swupdate-rollback.bb | 27 +++++++++++++++++++
4 files changed, 60 insertions(+)
create mode 100644 kas/opt/swupdate-rollback.yml
create mode 100644 recipes-core/swupdate-rollback/files/sysrq-panic.service
create mode 100644 recipes-core/swupdate-rollback/files/sysrq-panic.sh
create mode 100644 recipes-core/swupdate-rollback/swupdate-rollback.bb
diff --git a/kas/opt/swupdate-rollback.yml b/kas/opt/swupdate-rollback.yml
new file mode 100644
index 0000000..a3b0e28
--- /dev/null
+++ b/kas/opt/swupdate-rollback.yml
@@ -0,0 +1,19 @@
+#
+# CIP Core, generic profile
+#
+# Copyright (c) Toshiba Corporation, 2022
+#
+# Authors:
+# Shivanand Kunijadar <Shivanand.Kunijadar@...>
+#
+# SPDX-License-Identifier: MIT
+#
+# This kas file adds necessary scripts to cause kernel panic during system boot
+# which are required to test swupdate rollback feature
+
+header:
+ version: 10
+
+local_conf_header:
+ swupdate: |
+ IMAGE_INSTALL_append = " swupdate-rollback"
diff --git a/recipes-core/swupdate-rollback/files/sysrq-panic.service b/recipes-core/swupdate-rollback/files/sysrq-panic.service
new file mode 100644
index 0000000..ae868f9
--- /dev/null
+++ b/recipes-core/swupdate-rollback/files/sysrq-panic.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=sysrq panic
+
+[Service]
+Type=oneshot
+ExecStart=/root/sysrq-panic.sh
+
+[Install]
+WantedBy=default.target
+
diff --git a/recipes-core/swupdate-rollback/files/sysrq-panic.sh b/recipes-core/swupdate-rollback/files/sysrq-panic.sh
new file mode 100644
index 0000000..a3c1bb7
--- /dev/null
+++ b/recipes-core/swupdate-rollback/files/sysrq-panic.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo c > /proc/sysrq-trigger
Why not doing that directly in the service file (/bin/sh -c "...")?

Jan

+
diff --git a/recipes-core/swupdate-rollback/swupdate-rollback.bb b/recipes-core/swupdate-rollback/swupdate-rollback.bb
new file mode 100644
index 0000000..5c93bb5
--- /dev/null
+++ b/recipes-core/swupdate-rollback/swupdate-rollback.bb
@@ -0,0 +1,27 @@
+#
+# CIP Core, generic profile
+#
+# Copyright (c) Toshiba Corporation, 2022
+#
+# Authors:
+# Shivanand Kunijadar <Shivanand.Kunijadar@...>
+#
+# SPDX-License-Identifier: MIT
+#
+
+inherit dpkg-raw
+
+DESCRIPTION = "Script and service files to cause kernel panic"
+
+SRC_URI = " \
+ file://sysrq-panic.sh \
+ file://sysrq-panic.service"
+
+do_install() {
+ install -v -d ${D}/root
+ install -v -m 0755 ${WORKDIR}/sysrq-panic.sh ${D}/root/
+ install -v -d ${D}/lib/systemd/system
+ install -v -m 0644 ${WORKDIR}/sysrq-panic.service ${D}/lib/systemd/system/
+ install -v -d ${D}/etc/systemd/system/default.target.wants
+ ln -s /lib/systemd/system/sysrq-panic.service ${D}/etc/systemd/system/default.target.wants/
+}

--
Siemens AG, Technology
Competence Center Embedded Linux

Join cip-dev@lists.cip-project.org to automatically receive all group messages.