* [PATCH] os-posix: Expand setrlimit() syscall compatibility
@ 2024-06-14 5:14 Trent Huber
2024-06-14 13:30 ` Daniel P. Berrangé
0 siblings, 1 reply; 3+ messages in thread
From: Trent Huber @ 2024-06-14 5:14 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, pbonzini, Trent Huber
Darwin (I'm running version 19.6.0) uses a subtly different version
of the setrlimit() syscall as described in the COMPATIBILITY section
of the macOS man page. I adjusted the way the rlim_cur member is set
to accommodate and which shouldn't affect any non-Darwin systems.
Signed-off-by: Trent Huber <trentmhuber@gmail.com>
---
os-posix.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/os-posix.c b/os-posix.c
index a4284e2c07..5766346521 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -270,7 +270,7 @@ void os_setup_limits(void)
return;
}
- nofile.rlim_cur = nofile.rlim_max;
+ nofile.rlim_cur = OPEN_MAX < nofile.rlim_max ? OPEN_MAX : nofile.rlim_max;
if (setrlimit(RLIMIT_NOFILE, &nofile) < 0) {
warn_report("unable to set NOFILE limit: %s", strerror(errno));
--
2.24.3 (Apple Git-128)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] os-posix: Expand setrlimit() syscall compatibility
2024-06-14 5:14 [PATCH] os-posix: Expand setrlimit() syscall compatibility Trent Huber
@ 2024-06-14 13:30 ` Daniel P. Berrangé
2024-06-14 20:11 ` Trent Huber
0 siblings, 1 reply; 3+ messages in thread
From: Daniel P. Berrangé @ 2024-06-14 13:30 UTC (permalink / raw)
To: Trent Huber; +Cc: qemu-devel, qemu-trivial, pbonzini
On Fri, Jun 14, 2024 at 01:14:22AM -0400, Trent Huber wrote:
> Darwin (I'm running version 19.6.0) uses a subtly different version
> of the setrlimit() syscall as described in the COMPATIBILITY section
> of the macOS man page. I adjusted the way the rlim_cur member is set
> to accommodate and which shouldn't affect any non-Darwin systems.
>
> Signed-off-by: Trent Huber <trentmhuber@gmail.com>
> ---
> os-posix.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/os-posix.c b/os-posix.c
> index a4284e2c07..5766346521 100644
> --- a/os-posix.c
> +++ b/os-posix.c
> @@ -270,7 +270,7 @@ void os_setup_limits(void)
> return;
> }
>
> - nofile.rlim_cur = nofile.rlim_max;
> + nofile.rlim_cur = OPEN_MAX < nofile.rlim_max ? OPEN_MAX : nofile.rlim_max;
There's no such constant OPEN_MAX on Linux, so this doesn't compile.
There is a sysconf() parameter _SC_OPEN_MAX, but we should not use
that as it is a dynamic value that just reflects what 'rlim_cur'
is set to, and would thus turn this into a no-op.
This should just be made conditional to macOS, since its the only
problematic platform that we known of.
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] os-posix: Expand setrlimit() syscall compatibility
2024-06-14 13:30 ` Daniel P. Berrangé
@ 2024-06-14 20:11 ` Trent Huber
0 siblings, 0 replies; 3+ messages in thread
From: Trent Huber @ 2024-06-14 20:11 UTC (permalink / raw)
To: "Daniel P. Berrangé"; +Cc: qemu-devel, qemu-trivial, pbonzini
> On Jun 14, 2024, at 9:30 AM, Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Fri, Jun 14, 2024 at 01:14:22AM -0400, Trent Huber wrote:
>> Darwin (I'm running version 19.6.0) uses a subtly different version
>> of the setrlimit() syscall as described in the COMPATIBILITY section
>> of the macOS man page. I adjusted the way the rlim_cur member is set
>> to accommodate and which shouldn't affect any non-Darwin systems.
>>
>> Signed-off-by: Trent Huber <trentmhuber@gmail.com>
>> ---
>> os-posix.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/os-posix.c b/os-posix.c
>> index a4284e2c07..5766346521 100644
>> --- a/os-posix.c
>> +++ b/os-posix.c
>> @@ -270,7 +270,7 @@ void os_setup_limits(void)
>> return;
>> }
>>
>> - nofile.rlim_cur = nofile.rlim_max;
>> + nofile.rlim_cur = OPEN_MAX < nofile.rlim_max ? OPEN_MAX : nofile.rlim_max;
>
> There's no such constant OPEN_MAX on Linux, so this doesn't compile.
>
> There is a sysconf() parameter _SC_OPEN_MAX, but we should not use
> that as it is a dynamic value that just reflects what 'rlim_cur'
> is set to, and would thus turn this into a no-op.
>
> This should just be made conditional to macOS, since its the only
> problematic platform that we known of.
>
> With regards,
> Daniel
> --
> |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org -o- https://fstop138.berrange.com :|
> |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Thanks for looking this over, I'll add some conditionals and send a v2 of the patch.
Kindly,
Trent
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-14 20:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-14 5:14 [PATCH] os-posix: Expand setrlimit() syscall compatibility Trent Huber
2024-06-14 13:30 ` Daniel P. Berrangé
2024-06-14 20:11 ` Trent Huber
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).