]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virprocess: Drop workaround for setns() wrt old glibc
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 24 May 2022 08:21:11 +0000 (10:21 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 24 May 2022 14:15:29 +0000 (16:15 +0200)
We have our own implementation of setns() which was introduced in
v1.2.9-rc1~190 and extended afterwards. The reason was that back
in 2014 we were dealing with glibc that in some of its older
versions did not provide the function. Mostly for non-intel
arches. Nevertheless, glibc now offers the function for all
architectures we care about (aarch64 being the freshest
architecture where the function was introduced, in glibc-2.17).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
meson.build
src/util/virprocess.c

index a1c802b00d5f1d77c3299a1394b49d73fe224a3b..c4585bd92cc85e5bb2a8e301f00fc1d41bbbb452 100644 (file)
@@ -557,7 +557,6 @@ functions = [
   'prlimit',
   'sched_setscheduler',
   'setgroups',
-  'setns',
   'setrlimit',
   'symlink',
   'sysctlbyname',
index 36d7df050aa640aba45121a5f8d1b981217d6207..5ed0b5d0db80fda07af28060f5984873730de5ad 100644 (file)
@@ -27,7 +27,6 @@
 #ifndef WIN32
 # include <sys/wait.h>
 #endif
-#include <unistd.h>
 #if WITH_SYS_MOUNT_H
 # include <sys/mount.h>
 #endif
 
 VIR_LOG_INIT("util.process");
 
-#ifdef __linux__
-/*
- * 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
-#  elif defined(__arm__)
-#   define __NR_setns 375
-#  elif defined(__aarch64__)
-#   define __NR_setns 375
-#  elif defined(__powerpc__)
-#   define __NR_setns 350
-#  elif defined(__s390__)
-#   define __NR_setns 339
-#  endif
-# endif
-
-# ifndef WITH_SETNS
-#  if defined(__NR_setns)
-#   include <sys/syscall.h>
-
-static inline int setns(int fd, int nstype)
-{
-    return syscall(__NR_setns, fd, nstype);
-}
-#  else /* !__NR_setns */
-#   error Please determine the syscall number for setns on your architecture
-#  endif
-# endif
-#else /* !__linux__ */
-static inline int setns(int fd G_GNUC_UNUSED, int nstype G_GNUC_UNUSED)
-{
-    virReportSystemError(ENOSYS, "%s",
-                         _("Namespaces are not supported on this platform."));
-    return -1;
-}
-#endif
-
 VIR_ENUM_IMPL(virProcessSchedPolicy,
               VIR_PROC_POLICY_LAST,
               "none",
@@ -714,6 +670,7 @@ int virProcessGetNamespaces(pid_t pid,
 }
 
 
+#ifdef __linux__
 int virProcessSetNamespaces(size_t nfdlist,
                             int *fdlist)
 {
@@ -742,6 +699,16 @@ int virProcessSetNamespaces(size_t nfdlist,
     }
     return 0;
 }
+#else
+int virProcessSetNamespaces(size_t nfdlist G_GNUC_UNUSED,
+                            int *fdlist G_GNUC_UNUSED)
+{
+    virReportSystemError(ENOSYS, "%s",
+                         _("Namespaces are not supported on this platform."));
+    return -1;
+}
+#endif
+
 
 #if WITH_PRLIMIT
 static int