]> git.ipfire.org Git - thirdparty/lxc.git/commit
overlay and aufs clone_paths: be more robust
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 16 Oct 2014 15:10:21 +0000 (15:10 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 2 Dec 2014 17:20:04 +0000 (12:20 -0500)
commit1b49e7d03b44652db581c738e4f476201cbaaf1b
tree291933757d93b4c5e10c85bff35f3831adc93415
parentde1230232db796d739fe649d82467a8f346d57e5
overlay and aufs clone_paths: be more robust

Currently when we clone a container, bdev_copy passes NULL as dst argument
of bdev_init, then sees bdev->dest (as a result) is NULL, and sets
bdev->dest to $lxcpath/$name/rootfs.  so $ops->clone_paths() can
assume that "/rootfs" is at the end of the path.  The overlayfs and
aufs clonepaths do assume that and index to endofstring-6 and append
delta0.  Let's be more robust by actually finding the last / in
the path.

Then, instead of always setting oldbdev->dest to $lxcpath/$name/rootfs,
set it to oldbdev->src.  Else dir_clonepaths fails when mounting src
onto dest bc dest does not exist.  We could also fix that by creating
bdev->dest if needed, but that addes an empty directory to the old
container.

This fixes 'lxc-clone -o x1 -n x2' if x1 has lxc.rootfs = /var/lib/lxc/x1/x
and makes the overlayfs and aufs paths less fragile should something else
change.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/bdev.c