Michal Schmidt f3be58
From 68fd1b7fbb33996fd2849acf25bb364a834b5d74 Mon Sep 17 00:00:00 2001
Michal Schmidt a661db
From: Lennart Poettering <lennart@poettering.net>
Michal Schmidt a661db
Date: Tue, 6 Mar 2012 02:06:29 +0100
Michal Schmidt a661db
Subject: [PATCH] nspawn: be less cryptic when clone() fails
Michal Schmidt a661db
Michal Schmidt a661db
Based on a patch suggested by Shawn Landden.
Michal Schmidt a661db
(cherry picked from commit 52af21063b365f231ee6ae8bac18d690fff85799)
Michal Schmidt a661db
---
Michal Schmidt a661db
 src/nspawn.c |    9 +++++++--
Michal Schmidt a661db
 1 files changed, 7 insertions(+), 2 deletions(-)
Michal Schmidt a661db
Michal Schmidt a661db
diff --git a/src/nspawn.c b/src/nspawn.c
Michal Schmidt a661db
index 3ea603f..52b4aa8 100644
Michal Schmidt a661db
--- a/src/nspawn.c
Michal Schmidt a661db
+++ b/src/nspawn.c
Michal Schmidt a661db
@@ -705,8 +705,13 @@ int main(int argc, char *argv[]) {
Michal Schmidt a661db
         sigset_add_many(&mask, SIGCHLD, SIGWINCH, SIGTERM, SIGINT, -1);
Michal Schmidt a661db
         assert_se(sigprocmask(SIG_BLOCK, &mask, NULL) == 0);
Michal Schmidt a661db
 
Michal Schmidt a661db
-        if ((pid = syscall(__NR_clone, SIGCHLD|CLONE_NEWIPC|CLONE_NEWNS|CLONE_NEWPID|CLONE_NEWUTS|(arg_private_network ? CLONE_NEWNET : 0), NULL)) < 0) {
Michal Schmidt a661db
-                log_error("clone() failed: %m");
Michal Schmidt a661db
+        pid = syscall(__NR_clone, SIGCHLD|CLONE_NEWIPC|CLONE_NEWNS|CLONE_NEWPID|CLONE_NEWUTS|(arg_private_network ? CLONE_NEWNET : 0), NULL);
Michal Schmidt a661db
+        if (pid < 0) {
Michal Schmidt a661db
+                if (errno == EINVAL)
Michal Schmidt a661db
+                        log_error("clone() failed, do you have namespace support enabled in your kernel? (You need UTS, IPC, PID and NET namespacing built in): %m");
Michal Schmidt a661db
+                else
Michal Schmidt a661db
+                        log_error("clone() failed: %m");
Michal Schmidt a661db
+
Michal Schmidt a661db
                 goto finish;
Michal Schmidt a661db
         }
Michal Schmidt a661db