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.
This commit is contained in:
Michal Privoznik 2012-01-12 18:47:30 +01:00
parent 7bceae0fa6
commit d7320e799f
4 changed files with 17 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -19,3 +19,6 @@
#QEMU_AUDIO_DRV=sdl
#
#SDL_AUDIODRIVER=pulse
# Override the maximum number of opened files
#LIBVIRTD_NOFILES_LIMIT=2048

View File

@ -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/*