]> git.proxmox.com Git - mirror_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>
Mon, 27 Oct 2014 21:38:13 +0000 (17:38 -0400)
commitedf77341a57a81d8a5c9b9a767d8ba79f26ba8c4
tree2da172be9d208f30c897d81f2920fb7543c78791
parentcfa70b8824e3830482864f97e195f60c12ad9098
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