From 6b7c8fce5a311899c03c2e34ee91f43c7b739f69 Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Tue, 27 Feb 2024 15:58:27 +0100 Subject: [PATCH] meson: Check for sched_get_priority_min() virProcessSetScheduler() uses not just sched_setscheduler() but also sched_get_priority_{min,max}(). Currently we assume that the former being available implies that the latter are as well, but that's not the case for at least GNU/Hurd. Make sure all functions are actually available before attempting to use them. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- meson.build | 1 + src/util/virprocess.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 31d02e5b67..740f62d484 100644 --- a/meson.build +++ b/meson.build @@ -584,6 +584,7 @@ functions = [ 'posix_fallocate', 'posix_memalign', 'prlimit', + 'sched_get_priority_min', 'sched_getaffinity', 'sched_setscheduler', 'setgroups', diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 8e4440b45f..5cdf3e3eb9 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -1573,7 +1573,7 @@ virProcessExitWithStatus(int status) exit(value); } -#if WITH_SCHED_SETSCHEDULER +#if defined(WITH_SCHED_SETSCHEDULER) && defined(WITH_SCHED_GET_PRIORITY_MIN) static int virProcessSchedTranslatePolicy(virProcessSchedPolicy policy) @@ -1667,7 +1667,7 @@ virProcessSetScheduler(pid_t pid, return 0; } -#else /* ! WITH_SCHED_SETSCHEDULER */ +#else /* ! (defined(WITH_SCHED_SETSCHEDULER) && defined(WITH_SCHED_GET_PRIORITY_MIN)) */ int virProcessSetScheduler(pid_t pid G_GNUC_UNUSED, @@ -1682,7 +1682,7 @@ virProcessSetScheduler(pid_t pid G_GNUC_UNUSED, return -1; } -#endif /* !WITH_SCHED_SETSCHEDULER */ +#endif /* ! (defined(WITH_SCHED_SETSCHEDULER) && defined(WITH_SCHED_GET_PRIORITY_MIN)) */ /* * Get all stat fields for a process based on pid and tid: