containers / qm

QM is a containerized environment for running Functional Safety qm (Quality Management) software
https://github.com/containers/qm
GNU General Public License v2.0
20 stars 21 forks source link

tools: add qm-storage-settings #421

Closed dougsland closed 4 months ago

dougsland commented 4 months ago

setup calls storage() function to execute the initial storage configuration but it's not called during the ostree deploy as it's required to call /usr/share/qm/setup. This patch extract the logic from setup with few improvements and now can be called externally via ostree / osbuild / osbuild-auto.

dougsland commented 4 months ago

CI/CD failing with the agent-flood test which is related to #416

dougsland commented 4 months ago

/hold still executing a bunch of tests.

dougsland commented 4 months ago

Okay, the patch works in ostree and also regular images:

ostree

# ./runvm --nographics ./cs9-qemu-qmcontainer-ostree.x86_64.qcow2
BdsDxe: loading Boot0001 "UEFI Misc Device" from PciRoot(0x0)/Pci(0x3,0x0)
BdsDxe: starting Boot0001 "UEFI Misc Device" from PciRoot(0x0)/Pci(0x3,0x0)
System BootOrder not found.  Initializing defaults.
Creating boot entry "Boot0007" with label "CentOS Linux" for file "\EFI\centos\shimx64.efi"

  Booting `Automotive Stream Distribution 9 (ostree:0)'

Automotive Stream Distribution 9
Kernel 5.14.0-438.391.el9iv.x86_64 on an x86_64

localhost login: 
root
Password:

[root@localhost ~]# ls /ostree/.    # just proving it's ostree distro version
boot.1  boot.1.1  deploy  repo

[root@localhost ~]# cat /usr/lib/qm/rootfs/etc/containers/storage.conf
[storage]
driver = "overlay"
runroot = "/run/containers/storage"
graphroot = "/var/lib/containers/storage"
transient_store = true

[storage.options]
additionalimagestores = [
   "/usr/share/containers/storage",
   "/var/lib/shared"                                   <----------- Patch worked, the prove.
]

[storage.options.overlay]
mountopt = "nodev,metacopy=on"
[root@localhost ~]# cat /usr/lib/qm/rootfs/etc/containers/containers.conf
[containers]
default_sysctls = []

cgroup_conf=[
    "memory.oom.group=1",
]

oom_score_adj = 750

[engine]
env = ["TMPDIR=/var/tmp.images"]                    <----------- Patch worked, the prove.

[root@localhost ~]# podman ps
CONTAINER ID  IMAGE       COMMAND     CREATED        STATUS        PORTS       NAMES
e3181567cf0e              /sbin/init  3 minutes ago  Up 3 minutes              qm

root@localhost ~]# podman exec -it qm bash
bash-5.1# podman ps
CONTAINER ID  IMAGE                       COMMAND               CREATED        STATUS        PORTS       NAMES
e1afd146a8b9  localhost/auto-apps:latest  /usr/bin/radio-se...  3 minutes ago  Up 3 minutes              systemd-radio
4f3e00348899  localhost/auto-apps:latest  /usr/bin/engine-s...  3 minutes ago  Up 3 minutes              systemd-engine

regular

# ./runvm --nographics ./cs9-qemu-qmcontainer-regular.x86_64.qcow2
BdsDxe: loading Boot0001 "UEFI Misc Device" from PciRoot(0x0)/Pci(0x3,0x0)
BdsDxe: starting Boot0001 "UEFI Misc Device" from PciRoot(0x0)/Pci(0x3,0x0)
System BootOrder not found.  Initializing defaults.
Creating boot entry "Boot0007" with label "CentOS Linux" for file "\EFI\centos\shimx64.efi"

  Booting `Automotive Stream Distribution (5.14.0-438.391.el9iv.x86_64) 9'

[    1.657006] Error: Driver 'pcspkr' is already registered, aborting...
[    3.032014] overlayfs: idmapped layers are currently not supported
[    3.247801] Warning: Unmaintained driver is detected: nft_compat
[    4.447878] overlayfs: idmapped layers are currently not supported

Automotive Stream Distribution 9
Kernel 5.14.0-438.391.el9iv.x86_64 on an x86_64

localhost login: root
Password:

[root@localhost ~]# cat /etc/os-release
NAME="Automotive Stream Distribution"
VERSION="9"
ID="autosd"
ID_LIKE="rhel fedora centos"
VERSION_ID="9"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Automotive Stream Distribution 9"
ANSI_COLOR="0;31"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:centos:autosd:9"
HOME_URL="https://sig.centos.org/automotive/"
REDHAT_SUPPORT_PRODUCT="Automotive Stream Distribution"
REDHAT_SUPPORT_PRODUCT_VERSION="Automotive Stream Distribution 9"

[root@localhost ~]# cat /usr/lib/qm/rootfs/etc/containers/storage.conf
[storage]
driver = "overlay"
runroot = "/run/containers/storage"
graphroot = "/var/lib/containers/storage"
transient_store = true

[storage.options]
additionalimagestores = [
   "/usr/share/containers/storage",
   "/var/lib/shared"                                            <----------- Patch worked, the prove.
]

[storage.options.overlay]
mountopt = "nodev,metacopy=on"
[root@localhost ~]# cat /usr/lib/qm/rootfs/etc/containers/containers.conf
[containers]
default_sysctls = []

cgroup_conf=[
    "memory.oom.group=1",
]

oom_score_adj = 750

[engine]
env = ["TMPDIR=/var/tmp.images"]           <----------- Patch worked, the prove.
[root@localhost ~]#

[root@localhost ~]# podman ps
CONTAINER ID  IMAGE       COMMAND     CREATED        STATUS        PORTS       NAMES
d164f464bb10              /sbin/init  3 minutes ago  Up 3 minutes              qm

[root@localhost ~]# podman exec -it qm bash
bash-5.1# podman ps
CONTAINER ID  IMAGE                       COMMAND               CREATED        STATUS        PORTS       NAMES
96121288b5b5  localhost/auto-apps:latest  /usr/bin/engine-s...  3 minutes ago  Up 3 minutes              systemd-engine
87e9a01af3d6  localhost/auto-apps:latest  /usr/bin/radio-se...  3 minutes ago  Up 3 minutes              systemd-radio
bash-5.1#
dougsland commented 4 months ago

The full solution requires 3 patches:

containers/qm: tools: add qm-storage-settings. URL: https://github.com/containers/qm/pull/421

automotive/sample-images: qm: add org.osbuild-auto.qm.storage.settings. URL: https://gitlab.com/CentOS/automotive/sample-images/-/merge_requests/510

qm: add qm-storage-settings. URL: https://gitlab.com/CentOS/automotive/rpms/osbuild-auto/-/merge_requests/12

dougsland commented 4 months ago

Fixes: https://github.com/containers/qm/issues/422