]> git.proxmox.com Git - mirror_lxc.git/commit - configure.ac
lxc-ls: Fix support of --nesting for unpriv
authorStéphane Graber <stgraber@ubuntu.com>
Tue, 4 Mar 2014 18:20:10 +0000 (13:20 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 4 Mar 2014 22:33:28 +0000 (17:33 -0500)
commit5674a5bf3977aefa5f4acc811ea32e2f2326f3de
tree8862a9ab0b261e336fbd1356af56e54325f5c668
parent891c180ab1eeab2fe4a027136941e498f4d5ed46
lxc-ls: Fix support of --nesting for unpriv

This reworks the way lxc-ls works in nesting mode. In the past it'd use
attach_wait's subprocess function to call itself in the container's
namespace, carefully only attaching to the namespaces it needed.

This works great for system containers but not so much as soon as you
also need to attach to userns. Instead this fix moves all of the
container listing code into a get_containers function (hence the massive
diff, sorry), this function is then called recursively.

For running containers, the function is called through attach_wait
inside the container's namespace, for stopped container, the function is
simply called recursively with a base path (container's rootfs) in an
attempt to find containers that way.
Communication between the parent lxc-ls and the child lxc-ls is done
through a temporary fd and serialized state using json (similar to what
was done using stdout in the previous implementation).

As get_global_config_item unfortunately caches the values, there's no
easy way to figure out what the lxcpath should be for a root container
when running as non-root, so just use @LXCPATH@ for now and have
python do the parsing itself.

As a result, the following things now work as expected:
 - listing nested unprivileged containers (root containers inside unpriv)
 - listing nested containers when they're not running
 - filtering containers in nesting mode (only the first level is filtered)
 - copy with invalid config (used to traceback)

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
configure.ac
src/lxc/lxc-ls [deleted file]
src/lxc/lxc-ls.in [new file with mode: 0755]