]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
libxl: fix build on rather old systems
authorJan Beulich <JBeulich@suse.com>
Fri, 11 Jan 2019 10:09:35 +0000 (03:09 -0700)
committerWei Liu <wei.liu2@citrix.com>
Fri, 11 Jan 2019 15:02:00 +0000 (15:02 +0000)
CLONE_NEWIPC has been introduced in Linux 2.6.19 only (and into glibc
at around that time as well). Cope with it being undefined as well as
with the underlying kernel not knowing of it.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
tools/libxl/libxl_linux.c

index 6475cca64b9df62a43c00de8e6265afed8a3a6c8..a4c2f28dbfc61ede37d73911be4eecfdc9828cbf 100644 (file)
@@ -334,12 +334,24 @@ int libxl__local_dm_preexec_restrict(libxl__gc *gc)
     unsigned i;
 
     /* Unshare mount and IPC namespaces.  These are unused by QEMU. */
-    r = unshare(CLONE_NEWNS | CLONE_NEWIPC);
+    r = unshare(CLONE_NEWNS);
     if (r) {
-        LOGE(ERROR, "libxl: Mount and IPC namespace unfailed");
+        LOGE(ERROR, "libxl: Mount namespace unshare failed");
         return ERROR_FAIL;
     }
 
+#ifndef CLONE_NEWIPC /* Available as of Linux 2.6.19 / glibc 2.8 */
+# define CLONE_NEWIPC 0x08000000
+#endif
+    r = unshare(CLONE_NEWIPC);
+    if (r) {
+        if (r && errno != EINVAL) {
+            LOGE(ERROR, "libxl: IPC namespace unshare failed");
+            return ERROR_FAIL;
+        }
+        LOG(WARN, "libxl: IPC namespace unshare unavailable");
+    }
+
     /* Set various "easy" rlimits */
     for (i = 0; rlimits[i].resource != RLIMIT_NLIMITS; i++) {
         struct rlimit rlim;