[systemd-devel] Adding controllers

Bhasker C V bhasker at unixindia.com
Thu Mar 2 09:58:27 UTC 2017


Hi,

 I tried to look for information but could not get any.
 I have created a systemd unit which runs systemd-nspawn of my local
ubuntu rootfs.
 The unit has values to restrict cpu, memory etc.,

----
[Unit]
Description=ubuntu
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/systemd-nspawn --keep-unit -jbD /machines/ubuntu
CPUAcounting=yes
MemoryAccouting=yes
CPUShares=200
MemorySwapMax=1M
MemoryMax=1073741824
MemoryLimit=1073741824
CPUQuota=50%
TasksMax=100

[Install]
WantedBy=multi-user.target


[Manager]
JoinControllers=

---

>From what I can read from the man page, The joincontrollers is a list
of controllers the systemd unit will "not" join.. Please correct me if
my understanding is wrong.
I am however not able to make this systemd-nspawn join freezer controller.

The only way I am able to achieve this is


ExecStart=/usr/bin/cgexec -g freezer:/ubuntu /usr/bin/systemd-nspawn
--keep-unit -jbD /machines/ubuntu

(of course I use ExecStartPre to create the freezer:/ubuntu)


But I feel there must be more systemd-native elegant way to do this.
Please can someone guide me ?

thanks
Bhasker


More information about the systemd-devel mailing list