[libvirt PATCH] src: fix max file limits in systemd services

Daniel P. Berrangé posted 1 patch 9 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20230802090538.192161-1-berrange@redhat.com
src/ch/virtchd.service.in        | 2 +-
src/locking/virtlockd.service.in | 2 +-
src/logging/virtlogd.service.in  | 2 +-
src/lxc/virtlxcd.service.in      | 2 +-
src/qemu/virtqemud.service.in    | 2 +-
src/remote/libvirtd.service.in   | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
[libvirt PATCH] src: fix max file limits in systemd services
Posted by Daniel P. Berrangé 9 months, 1 week ago
This fixes

  commit 38abf9c34dc481b0dc923bdab446ee623bdc5ab6
  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>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/ch/virtchd.service.in        | 2 +-
 src/locking/virtlockd.service.in | 2 +-
 src/logging/virtlogd.service.in  | 2 +-
 src/lxc/virtlxcd.service.in      | 2 +-
 src/qemu/virtqemud.service.in    | 2 +-
 src/remote/libvirtd.service.in   | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/ch/virtchd.service.in b/src/ch/virtchd.service.in
index be242fea78..351eee312b 100644
--- a/src/ch/virtchd.service.in
+++ b/src/ch/virtchd.service.in
@@ -24,7 +24,7 @@ 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=512000:1024
+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
diff --git a/src/locking/virtlockd.service.in b/src/locking/virtlockd.service.in
index f1792dcb43..dd0bbab083 100644
--- a/src/locking/virtlockd.service.in
+++ b/src/locking/virtlockd.service.in
@@ -18,7 +18,7 @@ OOMScoreAdjust=-900
 # 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
+LimitNOFILE=1024:524288
 
 [Install]
 Also=virtlockd.socket
diff --git a/src/logging/virtlogd.service.in b/src/logging/virtlogd.service.in
index cef4053f59..8e245ddb43 100644
--- a/src/logging/virtlogd.service.in
+++ b/src/logging/virtlogd.service.in
@@ -18,7 +18,7 @@ OOMScoreAdjust=-900
 # 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
+LimitNOFILE=1024:524288
 
 [Install]
 Also=virtlogd.socket
diff --git a/src/lxc/virtlxcd.service.in b/src/lxc/virtlxcd.service.in
index b615a3f32d..ee3a7f1083 100644
--- a/src/lxc/virtlxcd.service.in
+++ b/src/lxc/virtlxcd.service.in
@@ -24,7 +24,7 @@ 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=512000:1024
+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
diff --git a/src/qemu/virtqemud.service.in b/src/qemu/virtqemud.service.in
index e3dc738b8f..e79670ca95 100644
--- a/src/qemu/virtqemud.service.in
+++ b/src/qemu/virtqemud.service.in
@@ -26,7 +26,7 @@ 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=512000:1024
+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
diff --git a/src/remote/libvirtd.service.in b/src/remote/libvirtd.service.in
index abac58cb2c..84f1613adc 100644
--- a/src/remote/libvirtd.service.in
+++ b/src/remote/libvirtd.service.in
@@ -31,7 +31,7 @@ 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=512000:1024
+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
-- 
2.41.0

Re: [libvirt PATCH] src: fix max file limits in systemd services
Posted by Martin Kletzander 9 months, 1 week ago
On Wed, Aug 02, 2023 at 10:05:38AM +0100, Daniel P. Berrangé wrote:
>This fixes
>
>  commit 38abf9c34dc481b0dc923bdab446ee623bdc5ab6
>  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
>

Pity we can't drop it because of systemd 239 still being in distros
supported by us.

>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>
>Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>