search for: fd_headroom

Displaying 1 result from an estimated 1 matches for "fd_headroom".

2017 Apr 20
1
[PATCH] tests: Replace test-max-disks with several tests.
...of open file descriptors (RLIMIT_NOFILE) + * + * =back + */ +static ssize_t +get_max_disks (guestfs_h *g) +{ + ssize_t ret; + struct rlimit rlim; + /* We reserve a little bit of "headroom" because qemu uses more + * file descriptors than just the disk files. + */ + const unsigned fd_headroom = 32; + + ret = guestfs_max_disks (g); + if (ret == -1) + return -1; + + if (getrlimit (RLIMIT_NOFILE, &rlim) == -1) { + perror ("getrlimit: RLIMIT_NOFILE"); + return -1; + } + if (rlim.rlim_cur > fd_headroom) { + if ((size_t) ret > rlim.rlim_cur - fd_headroom)...