Skip to content

Commit

Permalink
qm: document systemd drop-in plus QM
Browse files Browse the repository at this point in the history
The spec file change for AllowedCPU won't affect ostree systems.
This patch will document about using systemd drop-in plus QM.

Signed-off-by: Douglas Schilling Landgraf <[email protected]>
  • Loading branch information
dougsland committed Nov 30, 2023
1 parent 0b03bda commit aa080c3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
16 changes: 16 additions & 0 deletions qm.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ If you want permanently modify the bluechi agent within the QM you can add confi
/usr/lib/qm/rootfs/etc/bluechi/agent.conf.d/ directory or modify the /etc/containers/systemd/qm.container
quadlet file to not execute the bluechi-agent setup script.

## Using systemd drop-in with QM

The systemd drop-in feature allows users to extend or modify the configuration of systemd units without directly editing the unit files provided by the system package.

In this example, we will add the AllowedCPU to set as 1 to qm.service that quadlet generated:

**Create allowedcpus.conf**

```console
cat /etc/systemd/system/qm.service.d/allowedcpus.conf

# Contents of qm.continer.d/allowedcpus.conf
[Service]
AllowedCPUs=1
```

## SEE ALSO

**[podman(1)](https://github.com/containers/podman/blob/main/docs/source/markdown/podman.1.md)**,**[quadlet(5)](https://github.com/containers/podman/blob/main/docs/source/markdown/podman-systemd.unit.5.md)**, systemctl(1), systemd(1), dnf(8), [bluechi-agent(1)](https://github.com/containers/bluechi/blob/main/doc/man/bluechi-agent.1.md),[bluechi-agent.conf.5](https://github.com/containers/bluechi/blob/main/doc/man/bluechi-agent.conf.5.md)
3 changes: 2 additions & 1 deletion qm.container
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
WantedBy=default.target

[Service]
AllowedCPUs=1
# It's recommended to use systemd drop-in to override the
# systemd settings. See QM manpage for an example.
CPUWeight=50
Delegate=true
IOWeight=50
Expand Down
11 changes: 0 additions & 11 deletions rpm/qm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,6 @@ sed -i 's/^install: man all/install:/' Makefile
%_format MODULES %{_datadir}/selinux/packages/$x.pp.bz2
%selinux_modules_install -s %{selinuxtype} $MODULES

# Set AllowedCPUs in quadlet file
NPROC=$(nproc)
if [[ $NPROC == 1 ]]; then
ALLOWED_CPUS=0
elif [[ $NPROC == 2 ]]; then
ALLOWED_CPUS=1
else
ALLOWED_CPUS=$(expr $NPROC / 2)"-"$(expr $NPROC - 1)
fi
sed "s/^AllowedCPUs=.*/AllowedCPUs=$ALLOWED_CPUS/" %{_datadir}/containers/systemd/%{name}.container > %{_sysconfdir}/containers/systemd/%{name}.container

%postun
if [ $1 -eq 0 ]; then
%selinux_modules_uninstall -s %{selinuxtype} %{modulenames}
Expand Down

0 comments on commit aa080c3

Please sign in to comment.