[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 10/16] hw/9pfs: Update v9fs_set_fd_limit() for Windows
From: |
Bin Meng |
Subject: |
[PATCH v4 10/16] hw/9pfs: Update v9fs_set_fd_limit() for Windows |
Date: |
Mon, 30 Jan 2023 17:51:56 +0800 |
From: Guohuai Shi <guohuai.shi@windriver.com>
Use _getmaxstdio() to set the fd limit on Windows.
Signed-off-by: Guohuai Shi <guohuai.shi@windriver.com>
Signed-off-by: Bin Meng <bin.meng@windriver.com>
---
hw/9pfs/9p.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 2497a06f43..b55d0bc400 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -4396,11 +4396,28 @@ void v9fs_reset(V9fsState *s)
static void __attribute__((__constructor__)) v9fs_set_fd_limit(void)
{
+ int rlim_cur;
+ int ret;
+
+#ifndef CONFIG_WIN32
struct rlimit rlim;
- if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
+ ret = getrlimit(RLIMIT_NOFILE, &rlim);
+ rlim_cur = rlim.rlim_cur;
+#else
+ /*
+ * On Windows host, _getmaxstdio() actually returns the number of max
+ * open files at the stdio level. It *may* be smaller than the number
+ * of open files by open() or CreateFile().
+ */
+ ret = _getmaxstdio();
+ rlim_cur = ret;
+#endif
+
+ if (ret < 0) {
error_report("Failed to get the resource limit");
exit(1);
}
- open_fd_hw = rlim.rlim_cur - MIN(400, rlim.rlim_cur / 3);
- open_fd_rc = rlim.rlim_cur / 2;
+
+ open_fd_hw = rlim_cur - MIN(400, rlim_cur / 3);
+ open_fd_rc = rlim_cur / 2;
}
--
2.25.1
- [PATCH v4 00/16] hw/9pfs: Add 9pfs support for Windows, Bin Meng, 2023/01/30
- [PATCH v4 01/16] hw/9pfs: Add missing definitions for Windows, Bin Meng, 2023/01/30
- [PATCH v4 03/16] hw/9pfs: Replace the direct call to xxxdir() APIs with a wrapper, Bin Meng, 2023/01/30
- [PATCH v4 04/16] hw/9pfs: Implement Windows specific xxxdir() APIs, Bin Meng, 2023/01/30
- [PATCH v4 05/16] hw/9pfs: Update the local fs driver to support Windows, Bin Meng, 2023/01/30
- [PATCH v4 08/16] hw/9pfs: Add a helper qemu_stat_blksize(), Bin Meng, 2023/01/30
- [PATCH v4 02/16] hw/9pfs: Implement Windows specific utilities functions for 9pfs, Bin Meng, 2023/01/30
- [PATCH v4 07/16] hw/9pfs: Update helper qemu_stat_rdev(), Bin Meng, 2023/01/30
- [PATCH v4 10/16] hw/9pfs: Update v9fs_set_fd_limit() for Windows,
Bin Meng <=
- [PATCH v4 06/16] hw/9pfs: Support getting current directory offset for Windows, Bin Meng, 2023/01/30
- [PATCH v4 09/16] hw/9pfs: Disable unsupported flags and features for Windows, Bin Meng, 2023/01/30
- [PATCH v4 13/16] fsdev: Disable proxy fs driver on Windows, Bin Meng, 2023/01/30
- [PATCH v4 11/16] hw/9pfs: Add Linux error number definition, Bin Meng, 2023/01/30
- [PATCH v4 12/16] hw/9pfs: Translate Windows errno to Linux value, Bin Meng, 2023/01/30
- [PATCH v4 16/16] meson.build: Turn on virtfs for Windows, Bin Meng, 2023/01/30
- [PATCH v4 14/16] hw/9pfs: Update synth fs driver for Windows, Bin Meng, 2023/01/30
- [PATCH v4 15/16] tests/qtest: virtio-9p-test: Adapt the case for win32, Bin Meng, 2023/01/30
- Re: [PATCH v4 00/16] hw/9pfs: Add 9pfs support for Windows, Marc-André Lureau, 2023/01/31