char newpath[MAXPATHLEN];
int ret, storage_copied = 0;
const char *n, *l;
+ char *origroot = NULL;
struct clone_update_data data;
FILE *fout;
pid_t pid;
}
// copy the configuration, tweak it as needed,
+ if (c->lxc_conf->rootfs.path) {
+ origroot = c->lxc_conf->rootfs.path;
+ c->lxc_conf->rootfs.path = NULL;
+ }
fout = fopen(newpath, "w");
if (!fout) {
SYSERROR("open %s", newpath);
}
write_config(fout, c->lxc_conf);
fclose(fout);
+ c->lxc_conf->rootfs.path = origroot;
sprintf(newpath, "%s/%s/rootfs", l, n);
if (mkdir(newpath, 0755) < 0) {
ERROR("clone: failed to create new container (%s %s)", n, l);
goto out;
}
+ c2->lxc_conf->rootfs.path = origroot;
+
+ // copy/snapshot rootfs's
+ ret = copy_storage(c, c2, bdevtype, flags, bdevdata, newsize);
+ if (ret < 0)
+ goto out;
// update utsname
if (!set_config_item_locked(c2, "lxc.utsname", newname)) {
if (!(flags & LXC_CLONE_KEEPMACADDR))
network_new_hwaddrs(c2);
- // copy/snapshot rootfs's
- ret = copy_storage(c, c2, bdevtype, flags, bdevdata, newsize);
- if (ret < 0)
- goto out;
-
// We've now successfully created c2's storage, so clear it out if we
// fail after this
storage_copied = 1;