]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
src: set max open file limit to match systemd >= 240 defaults
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 21 Jun 2023 12:22:40 +0000 (13:22 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 20 Jul 2023 09:58:01 +0000 (10:58 +0100)
Since systemd 240, all services get an open file hard limit of
500k, and a soft limit of 1024. This limit means apps are safe
to use select() by default which is limited to 1024 FDs. Apps
which don't use select() are expected to simply set their soft
limit to match the hard limit during startup.

With our current unit file settings we've been effectively
reducing the max open files we have on most modern systems.

https://gitlab.com/libvirt/libvirt/-/issues/489
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/ch/virtchd.service.in
src/locking/virtlockd.service.in
src/logging/virtlogd.service.in
src/lxc/virtlxcd.service.in
src/qemu/virtqemud.service.in
src/remote/libvirtd.service.in

index 6e3b13446f5ed54e14ef852471ea7a6aea30300c..22314bc9070b1c107f2a715aaa7d74e2fdb2f6e4 100644 (file)
@@ -22,11 +22,10 @@ ExecStart=@sbindir@/virtchd $VIRTCHD_ARGS
 ExecReload=/bin/kill -HUP $MAINPID
 KillMode=process
 Restart=on-failure
-# At least 2 FD per guest (eg ch monitor + ch socket).
-# eg if we want to support 4096 guests, we'll typically need 8192 FDs
-# If changing this, also consider virtlogd.service & virtlockd.service
-# limits which are also related to number of guests
-LimitNOFILE=8192
+# Raise hard limits to match behaviour of systemd >= 240.
+# During startup, daemon will set soft limit to match hard limit
+# per systemd recommendations
+LimitNOFile=512000:1024
 # 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
index 23054369d5a98e8d5879eca599986dd096e4a1d1..f1792dcb4394dd549055bf236adaa781a61f75c9 100644 (file)
@@ -15,10 +15,10 @@ ExecReload=/bin/kill -USR1 $MAINPID
 # cause the machine to be fenced (rebooted), so make
 # sure we discourage OOM killer
 OOMScoreAdjust=-900
-# Needs to allow for max guests * average disks per guest
-# libvirtd.service written to expect 4096 guests, so if we
-# allow for 10 disks per guest, we get:
-LimitNOFILE=40960
+# Raise hard limits to match behaviour of systemd >= 240.
+# During startup, daemon will set soft limit to match hard limit
+# per systemd recommendations
+LimitNOFile=512000:1024
 
 [Install]
 Also=virtlockd.socket
index e4aecd46a76869e40f7366aeac417969939a40c8..cef4053f591ee4868c225a0bc66bdf5e9bb72a28 100644 (file)
@@ -15,13 +15,10 @@ ExecReload=/bin/kill -USR1 $MAINPID
 # cause the machine to be fenced (rebooted), so make
 # sure we discourage OOM killer
 OOMScoreAdjust=-900
-# Need to have at least one file open per guest (eg QEMU
-# stdio log), but might be more (eg serial console logs)
-# A common case is OpenStack which often has up to 4 file
-# handles per guest.
-# libvirtd.service written to expect 4096 guests, so if we
-# guess at 4 files per guest here that is 16k:
-LimitNOFILE=16384
+# Raise hard limits to match behaviour of systemd >= 240.
+# During startup, daemon will set soft limit to match hard limit
+# per systemd recommendations
+LimitNOFile=512000:1024
 
 [Install]
 Also=virtlogd.socket
index 06c70ccde22b1e921d38c53dd4181ce18b7d3bcc..59d7d26657c5234989dc5b78517e586f0826bf34 100644 (file)
@@ -22,11 +22,10 @@ ExecStart=@sbindir@/virtlxcd $VIRTLXCD_ARGS
 ExecReload=/bin/kill -HUP $MAINPID
 KillMode=process
 Restart=on-failure
-# At least 1 FD per guest, often 2 (eg qemu monitor + qemu agent).
-# eg if we want to support 4096 guests, we'll typically need 8192 FDs
-# If changing this, also consider virtlogd.service & virtlockd.service
-# limits which are also related to number of guests
-LimitNOFILE=8192
+# Raise hard limits to match behaviour of systemd >= 240.
+# During startup, daemon will set soft limit to match hard limit
+# per systemd recommendations
+LimitNOFile=512000:1024
 # 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
index 46917b746d28e65755944cf97dbadf657abc20a1..7e02f7ab51704bcf8032d2afcbb2a9f5185d7873 100644 (file)
@@ -24,11 +24,10 @@ ExecStart=@sbindir@/virtqemud $VIRTQEMUD_ARGS
 ExecReload=/bin/kill -HUP $MAINPID
 KillMode=process
 Restart=on-failure
-# At least 1 FD per guest, often 2 (eg qemu monitor + qemu agent).
-# eg if we want to support 4096 guests, we'll typically need 8192 FDs
-# If changing this, also consider virtlogd.service & virtlockd.service
-# limits which are also related to number of guests
-LimitNOFILE=8192
+# Raise hard limits to match behaviour of systemd >= 240.
+# During startup, daemon will set soft limit to match hard limit
+# per systemd recommendations
+LimitNOFile=512000:1024
 # 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
index afda257228b952bdbef4314b4852babd27087b1d..28bcdb1220ea61897250c2f8f38b64dd65199480 100644 (file)
@@ -29,11 +29,10 @@ ExecStart=@sbindir@/libvirtd $LIBVIRTD_ARGS
 ExecReload=/bin/kill -HUP $MAINPID
 KillMode=process
 Restart=on-failure
-# At least 1 FD per guest, often 2 (eg qemu monitor + qemu agent).
-# eg if we want to support 4096 guests, we'll typically need 8192 FDs
-# If changing this, also consider virtlogd.service & virtlockd.service
-# limits which are also related to number of guests
-LimitNOFILE=8192
+# Raise hard limits to match behaviour of systemd >= 240.
+# During startup, daemon will set soft limit to match hard limit
+# per systemd recommendations
+LimitNOFile=512000:1024
 # 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