diff mbox series

[isar-cip-core,v2,1/2] Add recipe to cause kernel panic during system boot

Message ID 20220201153502.14230-2-Shivanand.Kunijadar@toshiba-tsip.com (mailing list archive)
State New
Headers show
Series Add necessary steps to verify swupdate | expand

Commit Message

Shivanand.Kunijadar@toshiba-tsip.com Feb. 1, 2022, 3:35 p.m. UTC
From: Shivanand Kunijadar <Shivanand.Kunijadar@toshiba-tsip.com>

This recipe adds systemd service to cause kernel panic during system
boot.
It helps to check the swupdate-rollback feature.

Signed-off-by: Shivanand Kunijadar <Shivanand.Kunijadar@toshiba-tsip.com>
---
 kas/opt/kernel-panic.yml                      | 18 ++++++++++++++
 .../kernel-panic/files/sysrq-panic.service    | 10 ++++++++
 recipes-core/kernel-panic/kernel-panic.bb     | 24 +++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 kas/opt/kernel-panic.yml
 create mode 100644 recipes-core/kernel-panic/files/sysrq-panic.service
 create mode 100644 recipes-core/kernel-panic/kernel-panic.bb

Comments

Jan Kiszka Feb. 4, 2022, 6:50 a.m. UTC | #1
On 01.02.22 16:35, Shivanand.Kunijadar@toshiba-tsip.com wrote:
> From: Shivanand Kunijadar <Shivanand.Kunijadar@toshiba-tsip.com>
> 
> This recipe adds systemd service to cause kernel panic during system
> boot.
> It helps to check the swupdate-rollback feature.
> 
> Signed-off-by: Shivanand Kunijadar <Shivanand.Kunijadar@toshiba-tsip.com>
> ---
>  kas/opt/kernel-panic.yml                      | 18 ++++++++++++++
>  .../kernel-panic/files/sysrq-panic.service    | 10 ++++++++
>  recipes-core/kernel-panic/kernel-panic.bb     | 24 +++++++++++++++++++
>  3 files changed, 52 insertions(+)
>  create mode 100644 kas/opt/kernel-panic.yml
>  create mode 100644 recipes-core/kernel-panic/files/sysrq-panic.service
>  create mode 100644 recipes-core/kernel-panic/kernel-panic.bb
> 
> diff --git a/kas/opt/kernel-panic.yml b/kas/opt/kernel-panic.yml
> new file mode 100644
> index 0000000..47df7b1
> --- /dev/null
> +++ b/kas/opt/kernel-panic.yml
> @@ -0,0 +1,18 @@
> +#
> +# CIP Core, generic profile
> +#
> +# Copyright (c) Toshiba Corporation, 2022
> +#
> +# Authors:
> +#  Shivanand Kunijadar <Shivanand.Kunijadar@toshiba-tsip.com>
> +#
> +# SPDX-License-Identifier: MIT
> +#
> +# This kas file adds systemd service file to cause kernel panic during system boot.
> +
> +header:
> +  version: 10
> +
> +local_conf_header:
> +  kernel-panic: |
> +    IMAGE_INSTALL_append = " kernel-panic"
> diff --git a/recipes-core/kernel-panic/files/sysrq-panic.service b/recipes-core/kernel-panic/files/sysrq-panic.service
> new file mode 100644
> index 0000000..169a97c
> --- /dev/null
> +++ b/recipes-core/kernel-panic/files/sysrq-panic.service
> @@ -0,0 +1,10 @@
> +[Unit]
> +Description=sysrq panic
> +
> +[Service]
> +Type=oneshot
> +ExecStart=/bin/sh -c "echo c > /proc/sysrq-trigger"
> +
> +[Install]
> +WantedBy=default.target
> +
> diff --git a/recipes-core/kernel-panic/kernel-panic.bb b/recipes-core/kernel-panic/kernel-panic.bb
> new file mode 100644
> index 0000000..511febb
> --- /dev/null
> +++ b/recipes-core/kernel-panic/kernel-panic.bb
> @@ -0,0 +1,24 @@
> +#
> +# CIP Core, generic profile
> +#
> +# Copyright (c) Toshiba Corporation, 2022
> +#
> +# Authors:
> +#  Shivanand Kunijadar <Shivanand.Kunijadar@toshiba-tsip.com>
> +#
> +# SPDX-License-Identifier: MIT
> +#
> +
> +inherit dpkg-raw
> +
> +DESCRIPTION = "Systemd service file to cause kernel panic"
> +
> +SRC_URI = " \
> +    file://sysrq-panic.service"
> +
> +do_install() {
> +	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/
> +}

Applied already to next, dropping the extra new-line in sysrq-panic.service.

Thanks,
Jan
diff mbox series

Patch

diff --git a/kas/opt/kernel-panic.yml b/kas/opt/kernel-panic.yml
new file mode 100644
index 0000000..47df7b1
--- /dev/null
+++ b/kas/opt/kernel-panic.yml
@@ -0,0 +1,18 @@ 
+#
+# CIP Core, generic profile
+#
+# Copyright (c) Toshiba Corporation, 2022
+#
+# Authors:
+#  Shivanand Kunijadar <Shivanand.Kunijadar@toshiba-tsip.com>
+#
+# SPDX-License-Identifier: MIT
+#
+# This kas file adds systemd service file to cause kernel panic during system boot.
+
+header:
+  version: 10
+
+local_conf_header:
+  kernel-panic: |
+    IMAGE_INSTALL_append = " kernel-panic"
diff --git a/recipes-core/kernel-panic/files/sysrq-panic.service b/recipes-core/kernel-panic/files/sysrq-panic.service
new file mode 100644
index 0000000..169a97c
--- /dev/null
+++ b/recipes-core/kernel-panic/files/sysrq-panic.service
@@ -0,0 +1,10 @@ 
+[Unit]
+Description=sysrq panic
+
+[Service]
+Type=oneshot
+ExecStart=/bin/sh -c "echo c > /proc/sysrq-trigger"
+
+[Install]
+WantedBy=default.target
+
diff --git a/recipes-core/kernel-panic/kernel-panic.bb b/recipes-core/kernel-panic/kernel-panic.bb
new file mode 100644
index 0000000..511febb
--- /dev/null
+++ b/recipes-core/kernel-panic/kernel-panic.bb
@@ -0,0 +1,24 @@ 
+#
+# CIP Core, generic profile
+#
+# Copyright (c) Toshiba Corporation, 2022
+#
+# Authors:
+#  Shivanand Kunijadar <Shivanand.Kunijadar@toshiba-tsip.com>
+#
+# SPDX-License-Identifier: MIT
+#
+
+inherit dpkg-raw
+
+DESCRIPTION = "Systemd service file to cause kernel panic"
+
+SRC_URI = " \
+    file://sysrq-panic.service"
+
+do_install() {
+	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/
+}