mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
qemu_init: increase NOFILE soft limit on POSIX
In many configurations, e.g. multiple vNICs with multiple queues or with many Ceph OSDs, the default soft limit of 1024 is not enough. QEMU is supposed to work fine with file descriptors >= 1024 and does not use select() on POSIX. Bump the soft limit to the allowed hard limit to avoid issues with the aforementioned configurations. Of course the limit could be raised from the outside, but the man page of systemd.exec states about 'LimitNOFILE=': > Don't use. > [...] > Typically applications should increase their soft limit to the hard > limit on their own, if they are OK with working with file > descriptors above 1023, If the soft limit is already the same as the hard limit, avoid the superfluous setrlimit call. This can avoid a warning with a strict seccomp filter blocking setrlimit if NOFILE was already raised before executing QEMU. Buglink: https://bugzilla.proxmox.com/show_bug.cgi?id=4507 Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
52ed9f455e
commit
03e471c41d
4 changed files with 30 additions and 0 deletions
22
os-posix.c
22
os-posix.c
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include <sys/resource.h>
|
||||
#include <sys/wait.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
|
@ -256,6 +257,27 @@ void os_daemonize(void)
|
|||
}
|
||||
}
|
||||
|
||||
void os_setup_limits(void)
|
||||
{
|
||||
struct rlimit nofile;
|
||||
|
||||
if (getrlimit(RLIMIT_NOFILE, &nofile) < 0) {
|
||||
warn_report("unable to query NOFILE limit: %s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
if (nofile.rlim_cur == nofile.rlim_max) {
|
||||
return;
|
||||
}
|
||||
|
||||
nofile.rlim_cur = nofile.rlim_max;
|
||||
|
||||
if (setrlimit(RLIMIT_NOFILE, &nofile) < 0) {
|
||||
warn_report("unable to set NOFILE limit: %s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void os_setup_post(void)
|
||||
{
|
||||
int fd = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue