[libvirt] [PATCH] configure: Require setns in glibc

Michal Privoznik mprivozn at redhat.com
Mon Sep 15 15:41:38 UTC 2014


Instead of writing our own wrapper over setns function, require
it in glibc (when compiling with LXC). Our implementation uses
private macros from kernel header files which should not be done.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---

This is an alternative approach as requested by Martin.

 configure.ac          | 11 ++++++++++-
 src/util/virprocess.c | 33 ---------------------------------
 2 files changed, 10 insertions(+), 34 deletions(-)

diff --git a/configure.ac b/configure.ac
index b4fb99a..0366b78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -274,9 +274,18 @@ dnl Availability of various common functions (non-fatal if missing),
 dnl and various less common threadsafe functions
 AC_CHECK_FUNCS_ONCE([cfmakeraw fallocate geteuid getgid getgrnam_r \
   getmntent_r getpwuid_r getuid kill mmap newlocale posix_fallocate \
-  posix_memalign prlimit regexec sched_getaffinity setgroups setns \
+  posix_memalign prlimit regexec sched_getaffinity setgroups \
   setrlimit symlink sysctlbyname getifaddrs])
 
+AC_CHECK_FUNC([setns])
+if test "$ac_cv_func_setns" = "no" ; then
+    if "$with_lxc" = "check" ; then
+        with_lxc=no
+    elif "$with_lxc" = "yes" ; then
+        AC_MSG_ERROR([setns function is required for LXC])
+    fi
+fi
+
 dnl Availability of pthread functions. Because of $LIB_PTHREAD, we
 dnl cannot use AC_CHECK_FUNCS_ONCE. LIB_PTHREAD and LIBMULTITHREAD
 dnl were set during gl_INIT by gnulib.
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 3dae1bd..7c5f770 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -61,39 +61,6 @@
 
 VIR_LOG_INIT("util.process");
 
-/*
- * Workaround older glibc. While kernel may support the setns
- * syscall, the glibc wrapper might not exist. If that's the
- * case, use our own.
- */
-#ifndef __NR_setns
-# if defined(__x86_64__)
-#  define __NR_setns 308
-# elif defined(__i386__)
-#  define __NR_setns 346
-# else
-#  error "__NR_setns is not defined"
-# endif
-#endif
-
-#ifndef HAVE_SETNS
-# ifndef WIN32
-#  include <sys/syscall.h>
-
-static inline int setns(int fd, int nstype)
-{
-    return syscall(__NR_setns, fd, nstype);
-}
-# else
-static inline int setns(int fd ATTRIBUTE_UNUSED, int nstype ATTRIBUTE_UNUSED)
-{
-    virReportSystemError(ENOSYS, "%s",
-                         _("Namespaces are not supported on windows."));
-    return -1;
-}
-# endif /* WIN32 */
-#endif /* HAVE_SETNS */
-
 /**
  * virProcessTranslateStatus:
  * @status: child exit status to translate
-- 
1.8.5.5




More information about the libvir-list mailing list