From 681ed72b5c6877f05b2b7484520a29c55a3ec3fd Mon Sep 17 00:00:00 2001
From: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
Date: Tue, 26 Nov 2024 02:27:23 +0900
Subject: Re-enable drm lease test image

This patch enable drm-lease-test image that based on container manager.

Bug-AGL: SPEC-5308

Change-Id: I7301901d2ab0331a70dc031363c4133cea0bc532
Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
---
 .../images/agl-host-image-drm-lease-test.bbappend  |   5 +
 .../drm-lease-test-cluster.json                    |   3 +
 .../nanopct6/drm-lease-test-cluster.json           |  95 ++++++++++++++++
 .../system.conf.drm-lease-test-cluster.in          |   2 +
 .../cm-config-drm-lease-test-cluster_1.0.bb        |  25 +++++
 .../drm-lease-test-ivi.json                        |   3 +
 .../nanopct6/drm-lease-test-ivi.json               | 121 +++++++++++++++++++++
 .../system.conf.drm-lease-test-ivi.in              |   2 +
 .../cm-config-drm-lease-test-ivi_1.0.bb            |  23 ++++
 .../drm-lease-test-cluster.mount                   |  11 ++
 .../image-mount-drm-lease-test-cluster_1.0.bb      |  24 ++++
 .../drm-lease-test-ivi.mount                       |  11 ++
 .../image-mount-drm-lease-test-ivi_1.0.bb          |  24 ++++
 .../images/agl-host-image-drm-lease-test.bb        |  20 +++-
 14 files changed, 367 insertions(+), 2 deletions(-)
 create mode 100644 meta-agl-ic-container/dynamic-layers/meta-rockchip/recipes-platform/images/agl-host-image-drm-lease-test.bbappend
 create mode 100644 meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster/drm-lease-test-cluster.json
 create mode 100644 meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster/nanopct6/drm-lease-test-cluster.json
 create mode 100644 meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster/system.conf.drm-lease-test-cluster.in
 create mode 100644 meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster_1.0.bb
 create mode 100644 meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi/drm-lease-test-ivi.json
 create mode 100644 meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi/nanopct6/drm-lease-test-ivi.json
 create mode 100644 meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi/system.conf.drm-lease-test-ivi.in
 create mode 100644 meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi_1.0.bb
 create mode 100644 meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-cluster/drm-lease-test-cluster.mount
 create mode 100644 meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-cluster_1.0.bb
 create mode 100644 meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-ivi/drm-lease-test-ivi.mount
 create mode 100644 meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-ivi_1.0.bb

(limited to 'meta-agl-ic-container')

diff --git a/meta-agl-ic-container/dynamic-layers/meta-rockchip/recipes-platform/images/agl-host-image-drm-lease-test.bbappend b/meta-agl-ic-container/dynamic-layers/meta-rockchip/recipes-platform/images/agl-host-image-drm-lease-test.bbappend
new file mode 100644
index 00000000..138ee521
--- /dev/null
+++ b/meta-agl-ic-container/dynamic-layers/meta-rockchip/recipes-platform/images/agl-host-image-drm-lease-test.bbappend
@@ -0,0 +1,5 @@
+IMAGE_INSTALL:append = " \
+     linux-firmware-rtl8822 \
+     linux-firmware-rtl8125 \
+     rockchip-libmali-firmware \
+"
diff --git a/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster/drm-lease-test-cluster.json b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster/drm-lease-test-cluster.json
new file mode 100644
index 00000000..fc173b86
--- /dev/null
+++ b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster/drm-lease-test-cluster.json
@@ -0,0 +1,3 @@
+{
+	"name": "cluster-demo"
+}
diff --git a/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster/nanopct6/drm-lease-test-cluster.json b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster/nanopct6/drm-lease-test-cluster.json
new file mode 100644
index 00000000..c8f7e8da
--- /dev/null
+++ b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster/nanopct6/drm-lease-test-cluster.json
@@ -0,0 +1,95 @@
+{
+	"name": "drm-lease-test-cluster",
+	"role": "cluster",
+	"base": {
+		"autoboot": true,
+		"bootpriority": 1,
+		"rootfs": {
+			"path": "/opt/container/guests/drm-lease-test-cluster/rootfs",
+			"mode":		"rw",
+			"hostpath": [
+				"/var/lib/machines/guest1"
+			]
+		},
+		"lifecycle": {
+			"halt": "SIGRTMIN+3",
+			"reboot": "SIGTERM",
+			"timeout": 5000
+		},
+		"cap": {
+			"drop": "sys_module mac_admin mac_override sys_time",
+			"keep": ""
+		},
+		"environment": [
+			"HOME=/home/root"
+		]
+	},
+	"fs": {
+		"mount": [
+			{
+				"type": 	"filesystem",
+				"from": 	"tmpfs",
+				"to":		"run",
+				"fstype":	"tmpfs",
+				"option": 	"defaults 0 0"
+			},
+			{
+				"type": 	"directory",
+				"from": 	"/sys/kernel/security",
+				"to":		"sys/kernel/security",
+				"fstype":	"none",
+				"option": 	"ro,bind,optional 0 0"
+			},
+			{
+				"type": 	"directory",
+				"from": 	"/run/drm-lease-manager/lease-cluster",
+				"to":		"var/display/drm-lease-manager/lease",
+				"fstype":	"none",
+				"option": 	"bind,create=file"
+			},
+			{
+				"type": 	"directory",
+				"from": 	"/run/dlt",
+				"to":		"run/dlt",
+				"fstype":	"none",
+				"option": 	"bind,optional,create=dir"
+			}
+		]
+	},
+	"device": {
+		"static": [
+			{
+				"type": 		"devdir",
+				"from": 		"/dev/dri",
+				"to":			"dev/dri",
+				"devnode":		"/dev/dri/card0",
+				"optional": 		0,
+				"wideallow": 	1,
+				"exclusive": 	0
+			},
+			{
+				"type": 		"devnode",
+				"from": 		"/dev/mali0",
+				"to":			"dev/mali0",
+				"devnode":		"/dev/mali0",
+				"optional": 		0,
+				"wideallow": 	0,
+				"exclusive": 	0
+			}
+		]
+	},
+	"network": {
+		"static": [
+			{
+				"type": 	"veth",
+				"param": {
+					"name":	"veth0",
+					"link": 	"lxcbr0",
+					"flags":	"up",
+					"hwaddr":	"00:16:3e:xx:xx:xx",
+					"mode": "bridge"
+				}
+			}
+		]
+	}
+}
diff --git a/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster/system.conf.drm-lease-test-cluster.in b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster/system.conf.drm-lease-test-cluster.in
new file mode 100644
index 00000000..f496c589
--- /dev/null
+++ b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster/system.conf.drm-lease-test-cluster.in
@@ -0,0 +1,2 @@
+[Manager]
+#DefaultEnvironment =
diff --git a/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster_1.0.bb b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster_1.0.bb
new file mode 100644
index 00000000..80a794fe
--- /dev/null
+++ b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-cluster_1.0.bb
@@ -0,0 +1,25 @@
+DESCRIPTION = "Container Manager config for drm lease test cluster"
+LICENSE = "BSD-3-Clause"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9"
+
+
+SRC_URI = "file://drm-lease-test-cluster.json \
+           file://system.conf.drm-lease-test-cluster.in \
+          "
+
+inherit cm-config
+
+do_install:append() {
+    install -Dm644 ${WORKDIR}/drm-lease-test-cluster.json ${D}/opt/container/conf/drm-lease-test-cluster.json
+    install -d ${D}/opt/container/guests/drm-lease-test-cluster/rootfs
+    install -d ${D}/opt/container/guests/drm-lease-test-cluster/nv
+    install -d ${D}/opt/container/guests/drm-lease-test-cluster/shmounts
+}
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+FILES:${PN} += " \
+    /opt/container/conf/* \
+    /opt/container/guests/drm-lease-test-cluster/* \
+    "
+
diff --git a/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi/drm-lease-test-ivi.json b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi/drm-lease-test-ivi.json
new file mode 100644
index 00000000..b9828b6f
--- /dev/null
+++ b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi/drm-lease-test-ivi.json
@@ -0,0 +1,3 @@
+{
+	"name": "agl-momi-ivi-demo"
+}
diff --git a/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi/nanopct6/drm-lease-test-ivi.json b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi/nanopct6/drm-lease-test-ivi.json
new file mode 100644
index 00000000..cc0748bf
--- /dev/null
+++ b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi/nanopct6/drm-lease-test-ivi.json
@@ -0,0 +1,121 @@
+{
+	"name": "drm-lease-test-ivi",
+	"role": "ivi",
+	"base": {
+		"autoboot": true,
+		"bootpriority": 10,
+		"rootfs": {
+			"path": "/opt/container/guests/drm-lease-test-ivi/rootfs",
+			"mode":		"rw",
+			"hostpath": [
+				"/var/lib/machines/guest2"
+			]
+		},
+		"lifecycle": {
+			"halt": "SIGRTMIN+3",
+			"reboot": "SIGTERM",
+			"timeout": 15000
+		},
+		"cap": {
+			"drop": "sys_module mac_admin mac_override",
+			"keep": ""
+		},
+		"environment": [
+			"PIPEWIRE_RUNTIME_DIR=/var",
+			"HOME=/home/root"
+		]
+	},
+	"fs": {
+		"mount": [
+			{
+				"type": 	"filesystem",
+				"from": 	"tmpfs",
+				"to":		"run",
+				"fstype":	"tmpfs",
+				"option": 	"defaults 0 0"
+			},
+			{
+				"type": 	"directory",
+				"from": 	"/sys/kernel/security",
+				"to":		"sys/kernel/security",
+				"fstype":	"none",
+				"option": 	"ro,bind,optional 0 0"
+			},
+			{
+				"type": 	"directory",
+				"from": 	"/run/udev/data",
+				"to":		"run/udev/data",
+				"fstype":	"none",
+				"option": 	"ro,bind,optional,create=dir"
+			},
+			{
+				"type": 	"directory",
+				"from": 	"/run/drm-lease-manager/lease-ivi",
+				"to":		"var/display/drm-lease-manager/lease",
+				"fstype":	"none",
+				"option": 	"bind,create=file"
+			},
+			{
+				"type": 	"directory",
+				"from": 	"/run/dlt",
+				"to":		"run/dlt",
+				"fstype":	"none",
+				"option": 	"bind,optional,create=dir"
+			}
+		]
+	},
+	"device": {
+		"static": [
+			{
+				"type": 		"devdir",
+				"from": 		"/dev/dri",
+				"to":			"dev/dri",
+				"devnode":		"/dev/dri/card0",
+				"optional": 		0,
+				"wideallow": 	1,
+				"exclusive": 	0
+			},
+			{
+				"type": 		"devdir",
+				"from": 		"/dev/input",
+				"to":			"dev/input",
+				"devnode":		"/dev/input/event0",
+				"optional": 		1,
+				"wideallow": 	1,
+				"exclusive": 	0
+			},
+			{
+				"type": 		"devdir",
+				"from": 		"/dev/snd",
+				"to":			"dev/snd",
+				"devnode":		"/dev/snd/controlC0",
+				"optional": 		1,
+				"wideallow": 	1,
+				"exclusive": 	0
+			},
+			{
+				"type": 		"devnode",
+				"from": 		"/dev/mali0",
+				"to":			"dev/mali0",
+				"devnode":		"/dev/mali0",
+				"optional": 		0,
+				"wideallow": 	0,
+				"exclusive": 	0
+			}
+		]
+	},
+	"network": {
+		"static": [
+			{
+				"type": 	"veth",
+				"param": {
+					"name":	"eth0",
+					"link":	"lxcbr0",
+					"flags":	"up",
+					"hwaddr":	"00:16:3e:xx:xx:xx",
+					"mode": "bridge"
+				}
+			}
+		]
+	}
+}
diff --git a/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi/system.conf.drm-lease-test-ivi.in b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi/system.conf.drm-lease-test-ivi.in
new file mode 100644
index 00000000..f496c589
--- /dev/null
+++ b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi/system.conf.drm-lease-test-ivi.in
@@ -0,0 +1,2 @@
+[Manager]
+#DefaultEnvironment =
diff --git a/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi_1.0.bb b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi_1.0.bb
new file mode 100644
index 00000000..9d2d62f5
--- /dev/null
+++ b/meta-agl-ic-container/recipes-container/container-manager-config/cm-config-drm-lease-test-ivi_1.0.bb
@@ -0,0 +1,23 @@
+DESCRIPTION = "Container Manager config for drm lease test ivi"
+LICENSE = "BSD-3-Clause"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9"
+
+SRC_URI = "file://drm-lease-test-ivi.json \
+           file://system.conf.drm-lease-test-ivi.in \
+          "
+
+inherit cm-config
+
+do_install:append() {
+    install -Dm644 ${WORKDIR}/drm-lease-test-ivi.json ${D}/opt/container/conf/drm-lease-test-ivi.json
+    install -d ${D}/opt/container/guests/drm-lease-test-ivi/rootfs
+    install -d ${D}/opt/container/guests/drm-lease-test-ivi/nv
+    install -d ${D}/opt/container/guests/drm-lease-test-ivi/shmounts
+}
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+FILES:${PN} += " \
+    /opt/container/conf/* \
+    /opt/container/guests/drm-lease-test-ivi/* \
+    "
diff --git a/meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-cluster/drm-lease-test-cluster.mount b/meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-cluster/drm-lease-test-cluster.mount
new file mode 100644
index 00000000..8415cd8c
--- /dev/null
+++ b/meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-cluster/drm-lease-test-cluster.mount
@@ -0,0 +1,11 @@
+[Unit]
+Description=Image mount for drl-lease-test-cluster
+
+[Mount]
+What=/var/lib/machines/guest-image-drm-lease-test-cluster.ext4
+Where=/var/lib/machines/guest1
+Type=ext4
+Options=rw
+
+[Install]
+WantedBy=local-fs.target
diff --git a/meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-cluster_1.0.bb b/meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-cluster_1.0.bb
new file mode 100644
index 00000000..7ab01743
--- /dev/null
+++ b/meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-cluster_1.0.bb
@@ -0,0 +1,24 @@
+SUMMARY = "AGL CI guest image mounter for drm-lease-test-cluster."
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+SRC_URI += " \
+    file://drm-lease-test-cluster.mount \
+"
+
+inherit systemd
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE:${PN} = "var-lib-machines-guest1.mount"
+SYSTEMD_AUTO_ENABLE:${PN} = "enable"
+
+do_install:append () {
+    install -d ${D}${systemd_system_unitdir}
+    install -m 0644 ${WORKDIR}/drm-lease-test-cluster.mount  ${D}${systemd_system_unitdir}/var-lib-machines-guest1.mount
+    install -d ${D}/var/lib/machines/guest1
+}
+
+FILES:${PN} += " \
+    ${systemd_system_unitdir} \
+    /var/lib/machines/* \
+"
diff --git a/meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-ivi/drm-lease-test-ivi.mount b/meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-ivi/drm-lease-test-ivi.mount
new file mode 100644
index 00000000..252dc61c
--- /dev/null
+++ b/meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-ivi/drm-lease-test-ivi.mount
@@ -0,0 +1,11 @@
+[Unit]
+Description=Image mount for drl-lease-test-cluster
+
+[Mount]
+What=/var/lib/machines/guest-image-drm-lease-test-ivi.ext4
+Where=/var/lib/machines/guest2
+Type=ext4
+Options=rw
+
+[Install]
+WantedBy=local-fs.target
diff --git a/meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-ivi_1.0.bb b/meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-ivi_1.0.bb
new file mode 100644
index 00000000..2c0607f0
--- /dev/null
+++ b/meta-agl-ic-container/recipes-platform/drm-lease-test/image-mount-drm-lease-test-ivi_1.0.bb
@@ -0,0 +1,24 @@
+SUMMARY = "AGL CI guest image mounter for drm-lease-test-ivi."
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+SRC_URI += " \
+    file://drm-lease-test-ivi.mount \
+"
+
+inherit systemd
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE:${PN} = "var-lib-machines-guest2.mount"
+SYSTEMD_AUTO_ENABLE:${PN} = "enable"
+
+do_install:append () {
+    install -d ${D}${systemd_system_unitdir}
+    install -m 0644 ${WORKDIR}/drm-lease-test-ivi.mount ${D}${systemd_system_unitdir}/var-lib-machines-guest2.mount
+    install -d ${D}/var/lib/machines/guest2
+}
+
+FILES:${PN} += " \
+    ${systemd_system_unitdir} \
+    /var/lib/machines/* \
+"
diff --git a/meta-agl-ic-container/recipes-platform/images/agl-host-image-drm-lease-test.bb b/meta-agl-ic-container/recipes-platform/images/agl-host-image-drm-lease-test.bb
index 09b6ddac..5b751c0c 100644
--- a/meta-agl-ic-container/recipes-platform/images/agl-host-image-drm-lease-test.bb
+++ b/meta-agl-ic-container/recipes-platform/images/agl-host-image-drm-lease-test.bb
@@ -2,8 +2,7 @@ SUMMARY = "DRM Lease LXC test host image"
 LICENSE = "MIT"
 
 require lxc-host-image-minimal.bb
-require recipes-platform/images/agl-lxc-install-single-image.inc
-require recipes-platform/images/agl-lxc-autostart.inc
+require recipes-platform/images/agl-lxc-multiconfig-build.inc
 
 CONTAINER_IMAGES ?= "agl-container-ivi:guest-image-drm-lease-test-ivi \
                      agl-container-cluster:guest-image-drm-lease-test-cluster \
@@ -15,6 +14,9 @@ IMAGE_INSTALL += " \
 
 # packages required for network bridge settings via lxc-net
 IMAGE_INSTALL += " \
+    container-manager \
+    cm-config-drm-lease-test-cluster image-mount-drm-lease-test-cluster \
+    cm-config-drm-lease-test-ivi image-mount-drm-lease-test-ivi \
     lxc-networking \
     iptables-modules \
     dnsmasq \
@@ -23,5 +25,19 @@ IMAGE_INSTALL += " \
     kernel-module-xt-multiport \
 "
 
+install_container_images() {
+    for c in ${CONTAINER_IMAGES}; do
+        config=${c%:*}
+        image=${c#*:}
+        name=${image#guest-image-}
+        src="${TOPDIR}/tmp-${config}/deploy/images/${MACHINE}/${image}-${MACHINE}${MACHINE_SUFFIX}${IMAGE_NAME_SUFFIX}.ext4"
+        bbnote "Installing ${src}"
+        install -Dm644 ${src} ${IMAGE_ROOTFS}/var/lib/machines/${image}.ext4
+    done
+}
+
+ROOTFS_POSTPROCESS_COMMAND += "install_container_images; "
+
+
 # Under the this line, shall describe machine specific package.
 IMAGE_INSTALL:append:rcar-gen3 = " kernel-module-gles gles-user-module-firmware"
-- 
cgit 1.2.3-korg