[PATCH] build: fix build on non-Linux

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A cygwin build of 1.2.9 fails with:

util/virprocess.c:87:27: fatal error: sys/syscall.h: No such file or directory
 #  include <sys/syscall.h>

But in reality, the ONLY user of setns() is lxc, which is Linux-only.
It's easiest to just limit the setns workarounds to Linux.

* src/util/virprocess.c (setns): Limit definition to Linux.

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---

Pushing under the build-breaker rule.

 src/util/virprocess.c | 44 ++++++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 806e7f9..486123a 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -61,44 +61,48 @@

 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
+# 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
-#endif

-#ifndef HAVE_SETNS
-# if defined(__NR_setns) && !defined(WIN32)
-#  include <sys/syscall.h>
+# ifndef HAVE_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 && !WIN32 */
+#  else /* !__NR_setns */
+#   error Please determine the syscall number for setns on your architecture
+#  endif
+# endif
+#else /* !__linux__ */
 static inline int setns(int fd ATTRIBUTE_UNUSED, int nstype ATTRIBUTE_UNUSED)
 {
     virReportSystemError(ENOSYS, "%s",
                          _("Namespaces are not supported on this platform."));
     return -1;
 }
-# endif /* __NR_setns && !WIN32 */
-#endif /* HAVE_SETNS */
+#endif

 /**
  * virProcessTranslateStatus:
-- 
1.9.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]