]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
lxc_container: Turn lxcAttachNS into calling virProcessSetNamespaces
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 27 Aug 2015 00:59:29 +0000 (02:59 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 27 Aug 2015 13:05:52 +0000 (15:05 +0200)
Now that virProcessSetNamespaces() does accept FD list in the
correct format, we can simply turn lxcAttachNS into calling
virProcessSetNamespaces().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/lxc/lxc_container.c

index 125e1c80687830c91e761eb02a049c096d7e476d..a33465c3f169af53350f5abcad8dd579be779dc6 100644 (file)
@@ -2184,25 +2184,9 @@ static int lxcContainerDropCapabilities(virDomainDefPtr def ATTRIBUTE_UNUSED,
  */
 static int lxcAttachNS(int *ns_fd)
 {
-    size_t i;
-    if (ns_fd)
-        for (i = 0; i < VIR_LXC_DOMAIN_NAMESPACE_LAST; i++) {
-            if (ns_fd[i] < 0)
-                continue;
-            VIR_DEBUG("Setting into namespace\n");
-            /* We get EINVAL if new NS is same as the current
-             * NS, or if the fd namespace doesn't match the
-             * type passed to setns()'s second param. Since we
-             * pass 0, we know the EINVAL is harmless
-             */
-            if (setns(ns_fd[i], 0) < 0 &&
-                errno != EINVAL) {
-                virReportSystemError(errno, _("failed to set namespace '%s'"),
-                                     virLXCDomainNamespaceTypeToString(i));
-                return -1;
-            }
-            VIR_FORCE_CLOSE(ns_fd[i]);
-        }
+    if (ns_fd &&
+        virProcessSetNamespaces(VIR_LXC_DOMAIN_NAMESPACE_LAST, ns_fd) < 0)
+        return -1;
     return 0;
 }