[lxc-devel] clone: clear the rootfs out of unexpanded config

2015-11-11 Thread Serge Hallyn
Closes #694

When we start cloning container c1 to c2, we first save c1's
configuration in c2's as a starting point.  We long ago cleared
out the lxc.rootfs entry before saving it, so that if we are
killed before we update the rootfs, c2's rootfs doesn't point
to c1's.  Because then lxc-destroy -n c2 would delete c1's rootfs.

But when we introduced the unexpanded_config, we didn't update
this code to clear the rootfs out of the unexpanded_config, which
is what now actually gets saved in write_config().

Do so.

Signed-off-by: Serge Hallyn 
---
 src/lxc/lxccontainer.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 5207255..adc29c5 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -3057,7 +3057,7 @@ static struct lxc_container *do_lxcapi_clone(struct 
lxc_container *c, const char
struct lxc_container *c2 = NULL;
char newpath[MAXPATHLEN];
int ret, storage_copied = 0;
-   char *origroot = NULL;
+   char *origroot = NULL, *saved_unexp_conf = NULL;
struct clone_update_data data;
FILE *fout;
pid_t pid;
@@ -3104,9 +3104,20 @@ static struct lxc_container *do_lxcapi_clone(struct 
lxc_container *c, const char
SYSERROR("open %s", newpath);
goto out;
}
+
+   saved_unexp_conf = c->lxc_conf->unexpanded_config;
+   c->lxc_conf->unexpanded_config = strdup(saved_unexp_conf);
+   if (!c->lxc_conf->unexpanded_config) {
+   ERROR("Out of memory");
+   goto out;
+   }
+   clear_unexp_config_line(c->lxc_conf, "lxc.rootfs", false);
write_config(fout, c->lxc_conf);
fclose(fout);
c->lxc_conf->rootfs.path = origroot;
+   free(c->lxc_conf->unexpanded_config);
+   c->lxc_conf->unexpanded_config = saved_unexp_conf;
+   saved_unexp_conf = NULL;
 
sprintf(newpath, "%s/%s/rootfs", lxcpath, newname);
if (mkdir(newpath, 0755) < 0) {
-- 
2.5.0

___
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel


[lxc-devel] [PATCH 1/1] sleep 0.5s on reboot

2015-11-11 Thread Serge Hallyn
to give lxcfs' cgroup view time out.

Signed-off-by: Serge Hallyn 
---
 src/lxc/lxccontainer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 5207255..14c73b2 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -833,6 +833,7 @@ reboot:
if (conf->reboot == 1) {
INFO("container requested reboot");
conf->reboot = 2;
+   sleep(0.5); // let lxcfs' cgroup view time out
goto reboot;
}
 
-- 
2.5.0

___
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel