free(delta);
if (ret < 0 || ret >= len)
return -ENOMEM;
- } else if (strcmp(orig->type, "lvm") == 0) {
- ERROR("overlayfs clone of lvm container is not yet supported");
- // Note, supporting this will require overlayfs_mount supporting
- // mounting of the underlay. No big deal, just needs to be done.
- return -1;
} else if (strcmp(orig->type, "overlayfs") == 0) {
// What exactly do we want to do here?
// I think we want to use the original lowerdir, with a
free(ndelta);
if (ret < 0 || ret >= len)
return -ENOMEM;
+ } else {
+ ERROR("overlayfs clone of %s container is not yet supported",
+ orig->type);
+ // Note, supporting this will require overlayfs_mount supporting
+ // mounting of the underlay. No big deal, just needs to be done.
+ return -1;
}
return 0;
}
c2 = lxc_container_new(n, l);
- if (!c) {
+ if (!c2) {
ERROR("clone: failed to create new container (%s %s)", n, l);
goto out;
}
ret = copyhooks(c, c2);
if (ret < 0) {
ERROR("error copying hooks");
- c2->destroy(c2);
- lxc_container_put(c2);
goto out;
}
}
if (copy_fstab(c, c2) < 0) {
ERROR("error copying fstab");
- c2->destroy(c2);
- lxc_container_put(c2);
goto out;
}
// copy/snapshot rootfs's
ret = copy_storage(c, c2, bdevtype, flags, bdevdata, newsize);
- if (ret < 0) {
- c2->destroy(c2);
- lxc_container_put(c2);
+ if (ret < 0)
goto out;
- }
- if (!c2->save_config(c2, NULL)) {
- c2->destroy(c2);
- lxc_container_put(c2);
+ if (!c2->save_config(c2, NULL))
goto out;
- }
- if (clone_update_rootfs(c2, flags) < 0) {
- //c2->destroy(c2);
- lxc_container_put(c2);
+ if (clone_update_rootfs(c2, flags) < 0)
goto out;
- }
// TODO: update c's lxc.snapshot = count
lxcunlock(c->privlock);
out:
lxcunlock(c->privlock);
- if (c2)
+ if (c2) {
+ c2->destroy(c2);
lxc_container_put(c2);
+ }
return NULL;
}