lxc: shutdown $domain broken in 1.2.2

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

 



host: centos-6.5
kernel: 3.13.2-4.el6.x86_64
guest: fedora20

since libvirt-1.2.2 i can not shutdown this domain. works fine with
libvirt-1.2.1

# virsh shutdown fedora2
error: Failed to shutdown domain fedora2
error: Mount namespaces are not available on this platform: Function
not implemented

from the logfile: 14478: error : virProcessRunInMountNamespace:982 :
Mount namespaces are not available on this platform: Function not
implemented

the buildhost for the rpm is a centos-6.5 system with kernel 3.1.8
(dont ask! its a vserver system) and the test for "setns" failed

configure:9592: checking for setns
configure:9592: gcc -std=gnu99 -o conftest -g -O2   conftest.c  >&5
/tmp/cchlir6v.o: In function `main':
/builddir/build/BUILD/libvirt-1.2.2/conftest.c:184: undefined
reference to `setns'
collect2: ld returned 1 exit status

setns() was added in glibc-2.14 centos6 has glibc-2.12

attached is a fix for this problem.

stolen from: http://cgit.freedesktop.org/systemd/systemd/commit/src/shared/missing.h?id=3b794314149e40afaf3c456285e1e529747b6560

/stephan

-- 
Software is like sex, it's better when it's free!
diff -ubr libvirt-1.2.2/src/util/virprocess.c libvirt-1.2.2-patched/src/util/virprocess.c
--- libvirt-1.2.2/src/util/virprocess.c	2014-02-21 12:24:40.000000000 +0100
+++ libvirt-1.2.2-patched/src/util/virprocess.c	2014-03-03 13:19:30.000000000 +0100
@@ -534,7 +534,6 @@
 #endif /* HAVE_SCHED_GETAFFINITY */
 
 
-#if HAVE_SETNS
 int virProcessGetNamespaces(pid_t pid,
                             size_t *nfdlist,
                             int **fdlist)
@@ -605,26 +604,6 @@
     }
     return 0;
 }
-#else /* ! HAVE_SETNS */
-int virProcessGetNamespaces(pid_t pid,
-                            size_t *nfdlist ATTRIBUTE_UNUSED,
-                            int **fdlist ATTRIBUTE_UNUSED)
-{
-    virReportSystemError(ENOSYS,
-                         _("Cannot get namespaces for %llu"),
-                         (unsigned long long)pid);
-    return -1;
-}
-
-
-int virProcessSetNamespaces(size_t nfdlist ATTRIBUTE_UNUSED,
-                            int *fdlist ATTRIBUTE_UNUSED)
-{
-    virReportSystemError(ENOSYS, "%s",
-                         _("Cannot set namespaces"));
-    return -1;
-}
-#endif /* ! HAVE_SETNS */
 
 #if HAVE_PRLIMIT
 static int
@@ -880,7 +859,6 @@
 #endif
 
 
-#ifdef HAVE_SETNS
 static int virProcessNamespaceHelper(int errfd,
                                      pid_t pid,
                                      virProcessNamespaceCallback cb,
@@ -972,14 +950,3 @@
     VIR_FORCE_CLOSE(errfd[1]);
     return ret;
 }
-#else /* !HAVE_SETNS */
-int
-virProcessRunInMountNamespace(pid_t pid ATTRIBUTE_UNUSED,
-                              virProcessNamespaceCallback cb ATTRIBUTE_UNUSED,
-                              void *opaque ATTRIBUTE_UNUSED)
-{
-    virReportSystemError(ENOSYS, "%s",
-                         _("Mount namespaces are not available on this platform"));
-    return -1;
-}
-#endif
diff -ubr libvirt-1.2.2/src/util/virprocess.h libvirt-1.2.2-patched/src/util/virprocess.h
--- libvirt-1.2.2/src/util/virprocess.h	2014-02-21 12:24:40.000000000 +0100
+++ libvirt-1.2.2-patched/src/util/virprocess.h	2014-03-03 13:18:22.000000000 +0100
@@ -23,6 +23,8 @@
 # define __VIR_PROCESS_H__
 
 # include <sys/types.h>
+# include <unistd.h>
+# include <sys/syscall.h>
 
 # include "internal.h"
 # include "virbitmap.h"
@@ -71,4 +73,21 @@
 int virProcessRunInMountNamespace(pid_t pid,
                                   virProcessNamespaceCallback cb,
                                   void *opaque);
+
+#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
+static inline int setns(int fd, int nstype) {
+        return syscall(__NR_setns, fd, nstype);
+}
+#endif /* HAVE_SETNS */
+
 #endif /* __VIR_PROCESS_H__ */
--
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]