[xen staging] libxl: fix build on rather old systems

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen staging] libxl: fix build on rather old systems

patchbot
commit 1bce5f9baf0f4a4e50722f32b44afe4fdefc6b35
Author:     Jan Beulich <[hidden email]>
AuthorDate: Fri Jan 11 03:09:35 2019 -0700
Commit:     Wei Liu <[hidden email]>
CommitDate: Fri Jan 11 15:02:00 2019 +0000

    libxl: fix build on rather old systems
   
    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 <[hidden email]>
    Acked-by: Wei Liu <[hidden email]>
    Release-acked-by: Juergen Gross <[hidden email]>
---
 tools/libxl/libxl_linux.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_linux.c b/tools/libxl/libxl_linux.c
index 6475cca64b..a4c2f28dbf 100644
--- a/tools/libxl/libxl_linux.c
+++ b/tools/libxl/libxl_linux.c
@@ -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;
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog