From 1de5ae1a1e1f3ecf78da87e2e01138277e8b30c4 Mon Sep 17 00:00:00 2001 From: Leonardo Rossetti Date: Mon, 3 Nov 2025 09:36:21 -0300 Subject: [PATCH] autosd integration dir + lola demo Signed-off-by: Leonardo Rossetti --- .github/workflows/build_and_test_autosd.yml | 85 +++++++++++++ autosd/BUILD.bazel | 0 autosd/MODULE.bazel | 17 +++ autosd/build/.gitignore | 6 + autosd/build/README.md | 95 +++++++++++++++ autosd/build/files/bluechi-agent-main.conf | 15 +++ autosd/build/files/bluechi-agent-qm.conf | 15 +++ autosd/build/files/bluechi-controller.conf | 26 ++++ autosd/build/files/lola-ipc-pub.service | 27 +++++ autosd/build/files/lola-ipc-sub.service | 26 ++++ autosd/build/files/lola-ipc-test | 40 +++++++ autosd/build/files/lola-ipc-test.service | 21 ++++ autosd/build/lola-demo.aib.yml | 126 ++++++++++++++++++++ autosd/build/vars-devel.yml | 14 +++ autosd/build/vars.yml | 14 +++ autosd/scripts/run_qemu | 27 +++++ 16 files changed, 554 insertions(+) create mode 100644 .github/workflows/build_and_test_autosd.yml create mode 100644 autosd/BUILD.bazel create mode 100644 autosd/MODULE.bazel create mode 100644 autosd/build/.gitignore create mode 100644 autosd/build/README.md create mode 100644 autosd/build/files/bluechi-agent-main.conf create mode 100644 autosd/build/files/bluechi-agent-qm.conf create mode 100644 autosd/build/files/bluechi-controller.conf create mode 100644 autosd/build/files/lola-ipc-pub.service create mode 100644 autosd/build/files/lola-ipc-sub.service create mode 100755 autosd/build/files/lola-ipc-test create mode 100644 autosd/build/files/lola-ipc-test.service create mode 100644 autosd/build/lola-demo.aib.yml create mode 100644 autosd/build/vars-devel.yml create mode 100644 autosd/build/vars.yml create mode 100755 autosd/scripts/run_qemu diff --git a/.github/workflows/build_and_test_autosd.yml b/.github/workflows/build_and_test_autosd.yml new file mode 100644 index 0000000000..7883953e30 --- /dev/null +++ b/.github/workflows/build_and_test_autosd.yml @@ -0,0 +1,85 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +name: Build and Test AutoSD + +on: + pull_request: + paths: + - 'autosd/**' + workflow_dispatch: + +jobs: + build: + name: build-and-test-autosd + runs-on: ubuntu-latest + defaults: + run: + working-directory: autosd/build + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Bazel + uses: bazel-contrib/setup-bazel@0.9.1 + + - name: Install System Dependencies + run: | + sudo apt-get update -y + sudo apt-get install -y podman curl qemu-system + + - name: Install AIB Tools + run: | + curl -o auto-image-builder.sh "https://gitlab.com/CentOS/automotive/src/automotive-image-builder/-/raw/main/auto-image-builder.sh" + chmod +x auto-image-builder.sh + + curl -o automotive-image-runner "https://gitlab.com/CentOS/automotive/src/automotive-image-builder/-/raw/main/automotive-image-runner" + chmod +x automotive-image-runner + + - name: Build lola-demo.aib.yml + run: | + sudo ./auto-image-builder.sh build \ + --distro autosd10 \ + --mode package \ + --target qemu \ + --export qcow2 \ + --define-file vars.yml \ + --define-file vars-devel.yml \ + lola-demo.aib.yml \ + disk.qcow2 + + sudo chown $(id -u) disk.qcow2 + + mv disk.qcow2 ../disk.qcow2 + + - name: Enable KVM group perms + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + + - name: Test QEMU image + run: | + sshcmd() { + sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 root@localhost $@ + } + ./scripts/run_qemu + sshcmd 'cat /etc/os-release' + sleep 10 + sshcmd 'bluechictl start agent-qm lola-ipc-sub.service' + sleep 5 + sshcmd '/usr/local/bin/lola-ipc-test' + working-directory: ./autosd + env: + SSH_PASSWORD: password diff --git a/autosd/BUILD.bazel b/autosd/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/autosd/MODULE.bazel b/autosd/MODULE.bazel new file mode 100644 index 0000000000..2ad22c463b --- /dev/null +++ b/autosd/MODULE.bazel @@ -0,0 +1,17 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +module( + name = "score_ri_autosd", + version = "0.0.1", + compatibility_level = 0, +) diff --git a/autosd/build/.gitignore b/autosd/build/.gitignore new file mode 100644 index 0000000000..5c103a0641 --- /dev/null +++ b/autosd/build/.gitignore @@ -0,0 +1,6 @@ +_build/ +outputs/ +auto-image-builder.sh + +*.qcow2 +*.img diff --git a/autosd/build/README.md b/autosd/build/README.md new file mode 100644 index 0000000000..a738f2fd10 --- /dev/null +++ b/autosd/build/README.md @@ -0,0 +1,95 @@ +AutoSD MCO LoLa Demo +==================== + +## Background and Basic Info + +This demo build an AutoSD image using [Automotive-Image-Builder](https://gitlab.com/CentOS/automotive/src/automotive-image-builder). +This image comes pre-populated with the S-core's [communication](https://github.com/eclipse-score/communication) project packaged as RPM in a [COPR](https://copr.fedorainfracloud.org/coprs/pingou/score-playground/) repository as well as the [QM](https://github.com/containers/qm) project. + +The image is pre-configured to allow the communication project to send and receive messages within the root partition but also between the root partition and the QM partition. + + +Some things to know about this demo: +- The RPM packaging, currently, doesn't rely on Bazel. This is something that is being fixed, but in the current stage it is not there yet. +- Baselibs and communication have had to get some patches, some of which have already been sent upstream: + - Missing headers: https://github.com/eclipse-score/communication/pull/64 + - Missing headers: https://github.com/eclipse-score/baselibs/pull/19 + - Compilation issues on newer GCC + support for Linux ARM64: https://github.com/eclipse-score/baselibs/pull/22 + - Fix dangling references and compiler warnings for newer GCC: https://github.com/eclipse-score/communication/pull/68 + - Fix Google benchmark main function scope: https://github.com/eclipse-score/communication/pull/67 +- Other changes have not yet been sent upstream: + - Add the ability to configure the path where communication opens the shared memory segments: https://github.com/eclipse-score/communication/commit/127a64f07f48e1d69783dc20f217da813115dbe6 (not the final version of this change) + +The goal of this last commit is to avoid having to mount the entire `/dev/shm` into the QM partition and instead mount just a subfolder: `/dev/shm/lola_qm`. + + +## Building It + +A linux system is required to build this image but Ubuntu +and an OCI compliant container manager (docker, podman) should be enough. + +Download the builder script: + +``` +$ curl -o auto-image-builder.sh \ + "https://gitlab.com/CentOS/automotive/src/automotive-image-builder/-/raw/main/auto-image-builder.sh" +$ chmod +x automotive-image-builder +``` + +Build a qemu image by running: + +``` +sudo ./auto-image-builder.sh build \ +--define-file vars-devel.yml \ +--target qemu \ +--export qcow2 \ +--distro autosd10 lola-demo.aib.yml \ +autosd10-lola-x86_64.qcow2 +``` + +Change the image perms (if needed) since `sudo` was used: + +``` +sudo chown $(logname) autosd10-lola-x86_64.qcow2 +``` + +## Running/Testing the Demo + +You can run the qcow2 image with your qemu tool of choice and login into the image (either directly or over ssh) +with `root / password` (developer access defined by `vars-devel`). + +The image contains Systemd service defintions for LoLa, in both host and QM environemnts: + +- lola-ipc-sub.service +- lola-ipc-pub.service + +They can be used in the same environment or between them, to exemplify its mixed critical orchestration integration. + +For example, to run the publisher in the host environment while receiving messages in the QM one: + + +Start the subscriber in the QM partition: + +``` +# start the service +podman exec -it qm systemctl start lola-ipc-sub + +# check status +podman exec -it qm systemctl status lola-ipc-sub + +# get logs +podman exec -it qm journalctl -u lola-ipc-sub.service +``` + + +Start a publisher in the host environment: + +``` +systemctl start lola-ipc-pub +``` + +Check the QM process logs again with: + +``` +podman exec -it qm journalctl -u lola-ipc-sub.service +``` diff --git a/autosd/build/files/bluechi-agent-main.conf b/autosd/build/files/bluechi-agent-main.conf new file mode 100644 index 0000000000..63a52a150c --- /dev/null +++ b/autosd/build/files/bluechi-agent-main.conf @@ -0,0 +1,15 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +[bluechi-agent] +NodeName=agent-main +ControllerAddress=unix:path=/run/bluechi/bluechi.sock diff --git a/autosd/build/files/bluechi-agent-qm.conf b/autosd/build/files/bluechi-agent-qm.conf new file mode 100644 index 0000000000..ec97e88021 --- /dev/null +++ b/autosd/build/files/bluechi-agent-qm.conf @@ -0,0 +1,15 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +[bluechi-agent] +NodeName=agent-qm +ControllerAddress=unix:path=/run/bluechi/bluechi.sock diff --git a/autosd/build/files/bluechi-controller.conf b/autosd/build/files/bluechi-controller.conf new file mode 100644 index 0000000000..de800486c7 --- /dev/null +++ b/autosd/build/files/bluechi-controller.conf @@ -0,0 +1,26 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +[bluechi-controller] +ControllerPort=2020 +UseTCP=true +UseUDS=true +LogLevel=DEBUG +AllowedNodeNames=agent-main,agent-qm + +[node agent-main] +Allowed=true +AllowDependenciesOn=agent-main,agent-qm + +[node agent-qm] +Allowed=true +AllowDependenciesOn=agent-main,agent-qm diff --git a/autosd/build/files/lola-ipc-pub.service b/autosd/build/files/lola-ipc-pub.service new file mode 100644 index 0000000000..96f0b351d2 --- /dev/null +++ b/autosd/build/files/lola-ipc-pub.service @@ -0,0 +1,27 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +[Unit] +Description=LoLa IPC Publisher +After=network.target + +[Service] +Type=simple +WorkingDirectory=/usr/share/score-communication/examples/ipc_bridge/etc/ +ExecStart=/usr/bin/ipc_bridge_cpp --mode skeleton --num-cycles 5 --cycle-time 1000 --service_instance_manifest mw_com_config.json +Restart=on-failure +RestartSec=5 +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target + diff --git a/autosd/build/files/lola-ipc-sub.service b/autosd/build/files/lola-ipc-sub.service new file mode 100644 index 0000000000..e9b5510884 --- /dev/null +++ b/autosd/build/files/lola-ipc-sub.service @@ -0,0 +1,26 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +[Unit] +Requires=bluechi-proxy@agent-main_lola-ipc-pub.service +Description=LoLa IPC Subscriber +After=network.target + +[Service] +WorkingDirectory=/usr/share/score-communication/examples/ipc_bridge/etc/ +ExecStart=/usr/bin/ipc_bridge_cpp --mode proxy --num-cycles 5 --cycle-time 1000 --service_instance_manifest mw_com_config.json +Restart=on-failure +RestartSec=5 +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/autosd/build/files/lola-ipc-test b/autosd/build/files/lola-ipc-test new file mode 100755 index 0000000000..6ec3e45772 --- /dev/null +++ b/autosd/build/files/lola-ipc-test @@ -0,0 +1,40 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +#!/bin/bash +set -e + +BOOTSTRAP=${1:-false} +BOOSTRAP=$(echo "${BOOTSTRAP}" | tr '[:upper:]' '[:lower:]') + +if [[ "${BOOTSTRAP}" == "true" ]]; then + podman exec -it qm systemctl start lola-ipc-sub.service + systemctl start lola-ipc-pub.service + + sleep 60 +fi + +# check publisher logs +journalctl -u lola-ipc-pub | cat | grep -qE 'Sending sample: [0-9]+' +if [ "$?" -ne "0" ]; then + echo Could not match 'Sending sample: [0-9]+' from lola-ipc-pub.service logs. + exit $? +fi + +# check subscriber logs +podman exec -it qm journalctl -u lola-ipc-sub.service | cat | grep -qE 'Received sample: [0-9]+' +if [ "$?" -ne "0" ]; then + echo Could not match 'Received sample: [0-9]+' from lola-ipc-sub.service logs + exit $? +fi + +exit 0 diff --git a/autosd/build/files/lola-ipc-test.service b/autosd/build/files/lola-ipc-test.service new file mode 100644 index 0000000000..f0df530fd9 --- /dev/null +++ b/autosd/build/files/lola-ipc-test.service @@ -0,0 +1,21 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +[Unit] +Requires=bluechi-proxy@agent-qm_lola-ipc-sub.service +Requires=bluechi-proxy@agent-main_lola-ipc-pub.service +After=proxy@agent-main_lola-ipc-pub.service + +[Service] +Type=oneshot +ExecStart=/bin/bash /usr/local/bin/lola-ipc-test +RemainAfterExit=yes diff --git a/autosd/build/lola-demo.aib.yml b/autosd/build/lola-demo.aib.yml new file mode 100644 index 0000000000..f68cf86e9e --- /dev/null +++ b/autosd/build/lola-demo.aib.yml @@ -0,0 +1,126 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +# +name: esdv-score-lola-0.5 + +image: + selinux_mode: permissive +content: + enable_repos: + - devel + repos: + - id: epel + baseurl: https://dl.fedoraproject.org/pub/epel/10/Everything/$arch/ + - id: score + baseurl: https://download.copr.fedorainfracloud.org/results/pingou/score-playground/epel-10-$arch/ + rpms: + - vim-enhanced + - gdb + - strace + - boost-devel + - score-baselibs + - score-communication + - score-communication-performance-benchmarks + - score-communication-examples + - tree + - dnf + # For testing the image only: + - openssh-server + - openssh-clients + # bluechi packages + - bluechi-selinux + - bluechi-controller + - bluechi-agent + - bluechi-ctl + + make_dirs: + - path: /etc/containers/systemd/qm.container.d + mode: 0755 + parents: true + exist_ok: true + + # Configure shared socket directory via tmpfiles + add_files: + # lola config files + - path: /usr/lib/tmpfiles.d/lola_ipc.conf + text: | + # Lola shared memory segment folder + D! /dev/shm/lola_qm 0755 root root + - path: /usr/lib/tmpfiles.d/lola_disc.conf + text: | + # Lola service discovery folder + D! /tmp/mw_com_lola 0755 root root + - path: /etc/containers/systemd/qm.container.d/10-lola-ipc.conf + text: | + # Mount shared IPC directory for lola + [Container] + Volume=/dev/shm/lola_qm:/dev/shm/lola_qm + Volume=/tmp/mw_com_lola:/tmp/mw_com_lola + - path: /etc/containers/systemd/qm.container.d/11-bluechi-socket.conf + text: | + [Container] + Volume=/run/bluechi:/run/bluechi + # bluechi files + - path: /etc/bluechi/controller.conf.d/0-main.conf + source_path: files/bluechi-controller.conf + - path: /etc/bluechi/agent.conf.d/0-main.conf + source_path: files/bluechi-agent-main.conf + # lola service files + - path: /etc/systemd/system/lola-ipc-pub.service + source_path: files/lola-ipc-pub.service + # lola test script + - path: /usr/local/bin/lola-ipc-test + source_path: files/lola-ipc-test + chmod_files: + - path: /usr/local/bin/lola-ipc-test + mode: "0755" + + # Required for testing the image only: + systemd: + enabled_services: + # Enable ssh daemon + - sshd.service + - bluechi-controller.service + - bluechi-agent.service + +qm: + content: + enable_repos: + - devel + repos: + - id: epel + baseurl: https://dl.fedoraproject.org/pub/epel/10/Everything/$arch/ + - id: score + baseurl: https://download.copr.fedorainfracloud.org/results/pingou/score-playground/epel-10-$arch/ + rpms: + - boost-devel + - score-baselibs + - score-communication-examples + - score-communication + - bluechi-agent + add_files: + # lola service files + - path: /etc/systemd/system/lola-ipc-sub.service + source_path: files/lola-ipc-sub.service + # bluechi files + - path: /etc/bluechi/agent.conf.d/0-qm.conf + source_path: files/bluechi-agent-qm.conf + systemd: + enabled_services: + - bluechi-agent + +auth: + # Required for testing the image only: + sshd_config: + PasswordAuthentication: true + PermitRootLogin: true diff --git a/autosd/build/vars-devel.yml b/autosd/build/vars-devel.yml new file mode 100644 index 0000000000..cfebf2ebf2 --- /dev/null +++ b/autosd/build/vars-devel.yml @@ -0,0 +1,14 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +root_password: $6$xoLqEUz0cGGJRx01$H3H/bFm0myJPULNMtbSsOFd/2BnHqHkMD92Sfxd.EKM9hXTWSmELG8cf205l6dktomuTcgKGGtGDgtvHVXSWU. diff --git a/autosd/build/vars.yml b/autosd/build/vars.yml new file mode 100644 index 0000000000..f76998dd8f --- /dev/null +++ b/autosd/build/vars.yml @@ -0,0 +1,14 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +disable_ipv6: false diff --git a/autosd/scripts/run_qemu b/autosd/scripts/run_qemu new file mode 100755 index 0000000000..039b242a86 --- /dev/null +++ b/autosd/scripts/run_qemu @@ -0,0 +1,27 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +#!/bin/bash + +/usr/bin/qemu-system-x86_64 \ +-drive file=/usr/share/OVMF/OVMF_CODE_4M.fd,if=pflash,format=raw,unit=0,readonly=on \ +-drive file=/usr/share/OVMF/OVMF_VARS_4M.fd,if=pflash,format=raw,unit=1,snapshot=on,readonly=off \ +-enable-kvm \ +-m 5G \ +-smp $(nproc) \ +-machine q35 \ +-cpu host \ +-device virtio-net-pci,netdev=n0 \ +-netdev user,id=n0,hostfwd=tcp::2222-:22 \ +-daemonize \ +-display none \ +-drive file=disk.qcow2,index=0,media=disk,format=qcow2,if=virtio,id=rootdisk,snapshot=off