]> git.proxmox.com Git - mirror_lxc.git/commit
clone: don't ever mark the clone's rootfs as being the old, on disk
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Fri, 28 Feb 2014 03:49:27 +0000 (21:49 -0600)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 3 Mar 2014 16:03:20 +0000 (11:03 -0500)
commit8d2efe40a32700eaec6a8f3057b3b9bb16721b3d
tree8dbf2f5c39239291c97b19d936ea5b41e217a794
parent65db0e5a25839f24fd0f314b113b20dc48caf97b
clone: don't ever mark the clone's rootfs as being the old, on disk

Otherwise an interrupted clone can lead to the original rootfs
being delete.

There is a period during lxcapi_clone during which we have written down
a temporary configuration file on disk, for the new container, using the
old rootfs. Interruption of clone doesn't allow us to do the cleanup we
do in error paths, so a subsequent lxc-destroy removes the old rootfs.

Fix this by doing the copy_storage as early as possible, and not
writing down the rootfs when we write down the temporary configuration
file.

(note - I tested this by putting a series of
'if (strcmp(newname, "u%d") == 0) exit(1)' inline to trigger
interruption between most blocks.  If someone has a good idea
for a generic way to regression-test this henceforth that'd be
great)

See https://bugs.launchpad.net/lxc/+bug/1285850

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