Quoting zoolook (nbensa+lxcus...@gmail.com): > Hello, > > this is one is weird. lxc-clone removes the original volume if there's > no space to create a snapshot for the clone
D'oh, I'd believe it, yeah. How have I not run into this? Haven't tested, but the following should fix it: diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 0a3bd65..fe16f9d 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -1865,6 +1865,7 @@ struct lxc_container *lxcapi_clone(struct lxc_container *c, const char *newname, int ret; const char *n, *l; FILE *fout; + int storage_copied = 0; if (!c || !c->is_defined(c)) return NULL; @@ -1944,6 +1945,7 @@ struct lxc_container *lxcapi_clone(struct lxc_container *c, const char *newname, if (ret < 0) goto out; + storage_copied = 1; if (!c2->save_config(c2, NULL)) goto out; @@ -1957,6 +1959,11 @@ struct lxc_container *lxcapi_clone(struct lxc_container *c, const char *newname, out: container_mem_unlock(c); if (c2) { + if (!storage_copied) { + // Make sure we don't delete the original container's + // rootfs when we abort. + c->lxc_conf->rootfs.path = NULL; + } c2->destroy(c2); lxc_container_put(c2); } ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Lxc-users mailing list Lxc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-users