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 <abologna(a)redhat.com>
---
meson.build | 1 +
src/util/virprocess.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/meson.build b/meson.build
index a80a65e447..7f68c9da89 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:
--
2.43.2