Recently, FreeBSD has got sched_get/setaffinity(3) implementations and
the sched.h header as well [1]. To make these routines visible,
users have to define _WITH_CPU_SET_T.
This breaks current detection. Specifically, meson sees the
sched_getaffinity() symbol and defines WITH_SCHED_GETAFFINITY. This
define unlocks Linux implementation of virProcessSetAffinity() and other
functions, which fails to build on FreeBSD because cpu_set_t is not
visible as _WITH_CPU_SET_T is not defined.
For now, change detection to the following:
- Instead of checking sched_getaffinity(), check if 'cpu_set_t' is
available through sched.h
- Explicitly check the sched.h header instead of assuming its presence
if WITH_SCHED_SETSCHEDULER is defined
1:
https://cgit.freebsd.org/src/commit/?id=
43736b71dd051212d5c55be9fa21c45993017fbb
https://cgit.freebsd.org/src/commit/?id=
160b4b922b6021848b6b48afc894d16b879b7af2
https://cgit.freebsd.org/src/commit/?id=
90fa9705d5cd29cf11c5dc7319299788dec2546a
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
'posix_fallocate',
'posix_memalign',
'prlimit',
- 'sched_getaffinity',
'sched_setscheduler',
'setgroups',
'setns',
'net/if.h',
'pty.h',
'pwd.h',
+ 'sched.h',
'sys/auxv.h',
'sys/ioctl.h',
'sys/mount.h',
# Check for BSD approach for setting MAC addr
[ 'net/if_dl.h', 'link_addr', '#include <sys/types.h>\n#include <sys/socket.h>' ],
+
+ [ 'sched.h', 'cpu_set_t' ],
]
if host_machine.system() == 'linux'
# include <sys/time.h>
# include <sys/resource.h>
#endif
-#if WITH_SCHED_SETSCHEDULER
+#if WITH_SCHED_H
# include <sched.h>
#endif
return virProcessKillPainfullyDelay(pid, force, 0, false);
}
-#if WITH_SCHED_GETAFFINITY
+#if WITH_DECL_CPU_SET_T
int virProcessSetAffinity(pid_t pid, virBitmap *map, bool quiet)
{
return ret;
}
-#else /* WITH_SCHED_GETAFFINITY */
+#else /* WITH_DECL_CPU_SET_T */
int virProcessSetAffinity(pid_t pid G_GNUC_UNUSED,
virBitmap *map G_GNUC_UNUSED,
_("Process CPU affinity is not supported on this platform"));
return NULL;
}
-#endif /* WITH_SCHED_GETAFFINITY */
+#endif /* WITH_DECL_CPU_SET_T */
int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids)