[lxc-devel] [PATCH] lxc-ls: Detect missing setns support

Stéphane Graber stgraber at ubuntu.com
Wed Dec 11 19:05:57 UTC 2013


Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 src/lxc/lxc-ls | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 mode change 100644 => 100755 src/lxc/lxc-ls

diff --git a/src/lxc/lxc-ls b/src/lxc/lxc-ls
old mode 100644
new mode 100755
index 9d45400..26c9684
--- a/src/lxc/lxc-ls
+++ b/src/lxc/lxc-ls
@@ -172,6 +172,20 @@ if not os.geteuid() == 0 and (args.fancy or args.state):
                    "Try running: sudo %s"
                    % (sys.argv[0])))
 
+## Nesting requires setns to pid and net ns
+if args.nesting:
+    if not os.path.exists("/proc/self/ns/"):
+        parser.error(_("Showing nested containers requires setns support "
+                       "which your kernel doesn't support."))
+
+    if not "pid" in os.listdir("/proc/self/ns/"):
+        parser.error(_("Showing nested containers requires setns to the "
+                       "PID namespace which your kernel doesn't support."))
+
+    if not "net" in os.listdir("/proc/self/ns/"):
+        parser.error(_("Showing nested containers requires setns to the "
+                       "network namespace which your kernel doesn't support."))
+
 # List of containers, stored as dictionaries
 containers = []
 for container_name in lxc.list_containers(config_path=lxcpath):
-- 
1.8.5.1



More information about the lxc-devel mailing list