Re: [libvirt] [PATCH] lxc: ensure setns() syscall is defined

2015-08-28 Thread Guido Günther
Hi,
On Wed, Aug 26, 2015 at 03:53:43PM +0100, Daniel P. Berrange wrote:
 Older versions of glibc don't provide the setns() syscall
 function wrapper, so we must define it ourselves to prevent
 build failure on old distros.
 
 Signed-off-by: Daniel P. Berrange berra...@redhat.com
 
 Pushed as a RHEL-6 build-break fix

This also fixes the build on Debian Wheezy. Thanks!
 -- Guido

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


[libvirt] [PATCH] lxc: ensure setns() syscall is defined

2015-08-26 Thread Daniel P. Berrange
Older versions of glibc don't provide the setns() syscall
function wrapper, so we must define it ourselves to prevent
build failure on old distros.

Signed-off-by: Daniel P. Berrange berra...@redhat.com

Pushed as a RHEL-6 build-break fix

---
 src/lxc/lxc_container.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 8011ed0..feb8fad 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -95,6 +95,40 @@ VIR_LOG_INIT(lxc.lxc_container);
 # define CLONE_NEWNET  0x4000 /* New network namespace */
 #endif
 
+/*
+ * 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 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 */
+#  error Please determine the syscall number for setns on your architecture
+# endif
+#endif
+
 /* messages between parent and container */
 typedef char lxc_message_t;
 #define LXC_CONTINUE_MSG 'c'
-- 
2.4.3

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