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

Serge Hallyn serge.hallyn at ubuntu.com
Wed Dec 11 19:56:08 UTC 2013


Quoting Stéphane Graber (stgraber at ubuntu.com):
> Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>

Acked-by: Serge E. Hallyn <serge.hallyn 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
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


More information about the lxc-devel mailing list