From d7320e799f294fffdbccff87ac8e6d2d0fbcc41d Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 12 Jan 2012 18:47:30 +0100 Subject: [PATCH] daemon: Allow overriding NOFILES ulimit for the daemon as well One of my latest patches (d8db0f9690) created support for setting the limit for the maximum of opened files by qemu user. However, since libvirtd keeps one FD opened per domain (well, for qemu at least) it will likely hit this limit on huge scenarios. --- daemon/libvirtd.init.in | 7 +++++++ daemon/libvirtd.service.in | 2 ++ daemon/libvirtd.sysconf | 3 +++ daemon/libvirtd.upstart | 5 +++++ 4 files changed, 17 insertions(+) diff --git a/daemon/libvirtd.init.in b/daemon/libvirtd.init.in index 4e610cb231..3c49b1f017 100644 --- a/daemon/libvirtd.init.in +++ b/daemon/libvirtd.init.in @@ -60,6 +60,13 @@ start() { echo -n $"Starting $SERVICE daemon: " mkdir -p @localstatedir@/cache/libvirt rm -rf @localstatedir@/cache/libvirt/* + + # LIBVIRTD_NOFILES_LIMIT from /etc/sysconfig/libvirtd is not handled + # automatically + if [ -n "$LIBVIRTD_NOFILES_LIMIT" ]; then + ulimit -n "$LIBVIRTD_NOFILES_LIMIT" + fi + KRB5_KTNAME=$KRB5_KTNAME daemon --pidfile $PIDFILE --check $SERVICE $PROCESS --daemon $LIBVIRTD_CONFIG_ARGS $LIBVIRTD_ARGS RETVAL=$? echo diff --git a/daemon/libvirtd.service.in b/daemon/libvirtd.service.in index 9661428df6..8f2458af0c 100644 --- a/daemon/libvirtd.service.in +++ b/daemon/libvirtd.service.in @@ -15,6 +15,8 @@ Before=libvirt-guests.service EnvironmentFile=-/etc/sysconfig/libvirtd ExecStart=@sbindir@/libvirtd $LIBVIRTD_ARGS ExecReload=/bin/kill -HUP $MAINPID +# Override the maximum number of opened files +#LimitNOFILE=2048 [Install] WantedBy=multi-user.target diff --git a/daemon/libvirtd.sysconf b/daemon/libvirtd.sysconf index ab273c85f6..3af1f037d6 100644 --- a/daemon/libvirtd.sysconf +++ b/daemon/libvirtd.sysconf @@ -19,3 +19,6 @@ #QEMU_AUDIO_DRV=sdl # #SDL_AUDIODRIVER=pulse + +# Override the maximum number of opened files +#LIBVIRTD_NOFILES_LIMIT=2048 diff --git a/daemon/libvirtd.upstart b/daemon/libvirtd.upstart index f51701aa6c..e620f41450 100644 --- a/daemon/libvirtd.upstart +++ b/daemon/libvirtd.upstart @@ -31,6 +31,11 @@ script ulimit -c "$DAEMON_COREFILE_LIMIT" fi + # LIBVIRTD_NOFILES_LIMIT from /etc/sysconfig/libvirtd is not handled + # automatically + if [ -n "$LIBVIRTD_NOFILES_LIMIT" ]; then + ulimit -n "$LIBVIRTD_NOFILES_LIMIT" + fi mkdir -p /var/cache/libvirt rm -rf /var/cache/libvirt/*