public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu] fix #4507: add patch to automatically increase NOFILE soft limit
Date: Tue, 12 Dec 2023 14:42:35 +0100	[thread overview]
Message-ID: <20231212134235.659521-1-f.ebner@proxmox.com> (raw)

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.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 ...-increase-NOFILE-soft-limit-on-POSIX.patch | 97 +++++++++++++++++++
 debian/patches/series                         |  1 +
 2 files changed, 98 insertions(+)
 create mode 100644 debian/patches/pve/0047-qemu_init-increase-NOFILE-soft-limit-on-POSIX.patch

diff --git a/debian/patches/pve/0047-qemu_init-increase-NOFILE-soft-limit-on-POSIX.patch b/debian/patches/pve/0047-qemu_init-increase-NOFILE-soft-limit-on-POSIX.patch
new file mode 100644
index 0000000..2ee0676
--- /dev/null
+++ b/debian/patches/pve/0047-qemu_init-increase-NOFILE-soft-limit-on-POSIX.patch
@@ -0,0 +1,97 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Fiona Ebner <f.ebner@proxmox.com>
+Date: Tue, 12 Dec 2023 14:27:43 +0100
+Subject: [PATCH] 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.
+
+Buglink: https://bugzilla.proxmox.com/show_bug.cgi?id=4507
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
+---
+ include/sysemu/os-posix.h |  1 +
+ include/sysemu/os-win32.h |  5 +++++
+ os-posix.c                | 18 ++++++++++++++++++
+ softmmu/vl.c              |  2 ++
+ 4 files changed, 26 insertions(+)
+
+diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h
+index 1030d39904..edc415aff5 100644
+--- a/include/sysemu/os-posix.h
++++ b/include/sysemu/os-posix.h
+@@ -48,6 +48,7 @@ void os_setup_early_signal_handling(void);
+ void os_set_proc_name(const char *s);
+ void os_setup_signal_handling(void);
+ void os_daemonize(void);
++void os_setup_limits(void);
+ void os_setup_post(void);
+ int os_mlock(void);
+ 
+diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
+index 91aa0d7ec0..f6e23fe01e 100644
+--- a/include/sysemu/os-win32.h
++++ b/include/sysemu/os-win32.h
+@@ -129,6 +129,11 @@ static inline int os_mlock(void)
+     return -ENOSYS;
+ }
+ 
++void os_setup_limits(void)
++{
++    return;
++}
++
+ #define fsync _commit
+ 
+ #if !defined(lseek)
+diff --git a/os-posix.c b/os-posix.c
+index fb2ad87009..9f8261320e 100644
+--- a/os-posix.c
++++ b/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>
+@@ -288,6 +289,23 @@ 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;
++    }
++
++    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;
+diff --git a/softmmu/vl.c b/softmmu/vl.c
+index 20ba2c5c87..fde2be6893 100644
+--- a/softmmu/vl.c
++++ b/softmmu/vl.c
+@@ -2723,6 +2723,8 @@ void qemu_init(int argc, char **argv)
+     error_init(argv[0]);
+     qemu_init_exec_dir(argv[0]);
+ 
++    os_setup_limits();
++
+     qemu_init_arch_modules();
+ 
+     qemu_init_subsystems();
diff --git a/debian/patches/series b/debian/patches/series
index 7dcedcb..b19d81a 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -61,3 +61,4 @@ pve/0043-alloc-track-fix-deadlock-during-drop.patch
 pve/0044-migration-for-snapshots-hold-the-BQL-during-setup-ca.patch
 pve/0045-savevm-async-don-t-hold-BQL-during-setup.patch
 pve/0046-virtio-blk-scsi-work-around-iothread-polling-getting.patch
+pve/0047-qemu_init-increase-NOFILE-soft-limit-on-POSIX.patch
-- 
2.39.2





             reply	other threads:[~2023-12-12 13:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-12 13:42 Fiona Ebner [this message]
2023-12-12 15:17 ` Fiona Ebner
2024-02-05 13:16 ` Fiona Ebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231212134235.659521-1-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal