libvirt/src/ch/virtchd.service.in
Daniel P. Berrangé 3d2f3fb72b src: fix max file limits in systemd services
This fixes

  commit 38abf9c34d
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Wed Jun 21 13:22:40 2023 +0100

    src: set max open file limit to match systemd >= 240 defaults

The bug referenced in that commit had suggested to set

  LimitNOFile=512000:1024

on the basis that matches current systemd default behaviour and is
compatible with old systemd. That was good except

 * The setting is LimitNOFILE and these are case sensitive
 * The hard and soft limits were inverted - soft must come
   first and so it would have been ignored even if the
   setting name was correct.
 * The default hard limit is 524288 not 512000

Reported-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2023-08-04 13:00:52 +01:00

45 lines
1.4 KiB
SYSTEMD

[Unit]
Description=Virtualization Cloud-Hypervisor daemon
Conflicts=libvirtd.service
Requires=virtchd.socket
Requires=virtchd-ro.socket
Requires=virtchd-admin.socket
Wants=systemd-machined.service
After=network.target
After=dbus.service
After=apparmor.service
After=remote-fs.target
After=systemd-machined.service
Documentation=man:virtchd(8)
Documentation=https://libvirt.org
[Service]
Type=notify
Environment=VIRTCHD_ARGS="--timeout 120"
EnvironmentFile=-@initconfdir@/virtchd
ExecStart=@sbindir@/virtchd $VIRTCHD_ARGS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
# Raise hard limits to match behaviour of systemd >= 240.
# During startup, daemon will set soft limit to match hard limit
# per systemd recommendations
LimitNOFILE=1024:524288
# The cgroups pids controller can limit the number of tasks started by
# the daemon, which can limit the number of domains for some hypervisors.
# A conservative default of 8 tasks per guest results in a TasksMax of
# 32k to support 4096 guests.
TasksMax=32768
# With cgroups v2 there is no devices controller anymore, we have to use
# eBPF to control access to devices. In order to do that we create a eBPF
# hash MAP which locks memory. The default map size for 64 devices together
# with program takes 12k per guest. After rounding up we will get 64M to
# support 4096 guests.
LimitMEMLOCK=64M
[Install]
WantedBy=multi-user.target
Also=virtchd.socket
Also=virtchd-ro.socket
Also=virtchd-admin.socket