overlay: adapt to new config rootfs parser

parent 63c9ffa0
...@@ -4054,8 +4054,8 @@ static bool do_lxcapi_snapshot_restore(struct lxc_container *c, const char *snap ...@@ -4054,8 +4054,8 @@ static bool do_lxcapi_snapshot_restore(struct lxc_container *c, const char *snap
if (!strcmp(bdev->type, "overlay") || !strcmp(bdev->type, "overlayfs")) if (!strcmp(bdev->type, "overlay") || !strcmp(bdev->type, "overlayfs"))
flags |= LXC_STORAGE_INTERNAL_OVERLAY_RESTORE; flags |= LXC_STORAGE_INTERNAL_OVERLAY_RESTORE;
rest = lxcapi_clone(snap, newname, c->config_path, flags, rest = lxcapi_clone(snap, newname, c->config_path, flags, bdev->type,
bdev->type, NULL, 0, NULL); NULL, 0, NULL);
storage_put(bdev); storage_put(bdev);
if (rest && lxcapi_is_defined(rest)) if (rest && lxcapi_is_defined(rest))
b = true; b = true;
......
...@@ -199,12 +199,11 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char ...@@ -199,12 +199,11 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
return -22; return -22;
} }
nsrc = strchr(osrc, ':') + 1; nsrc = osrc;
if ((nsrc != osrc + 8) && (nsrc != osrc + 10)) { if (strncmp(osrc, "overlay:", 8) == 0)
ERROR("Detected \":\" in \"%s\" at wrong position", osrc); nsrc += 8;
free(osrc); else if (strncmp(osrc, "overlayfs:", 10) == 0)
return -22; nsrc += 10;
}
odelta = strchr(nsrc, ':'); odelta = strchr(nsrc, ':');
if (!odelta) { if (!odelta) {
...@@ -457,22 +456,17 @@ int ovl_create(struct lxc_storage *bdev, const char *dest, const char *n, ...@@ -457,22 +456,17 @@ int ovl_create(struct lxc_storage *bdev, const char *dest, const char *n,
int ovl_destroy(struct lxc_storage *orig) int ovl_destroy(struct lxc_storage *orig)
{ {
bool ovl;
char *upper = orig->src; char *upper = orig->src;
ovl = !strncmp(upper, "overlay:", 8);
if (!ovl && strncmp(upper, "overlayfs:", 10))
return -22;
/* For an overlay container the rootfs is considered immutable /* For an overlay container the rootfs is considered immutable
* and cannot be removed when restoring from a snapshot. * and cannot be removed when restoring from a snapshot.
*/ */
if (orig->flags & LXC_STORAGE_INTERNAL_OVERLAY_RESTORE) if (orig->flags & LXC_STORAGE_INTERNAL_OVERLAY_RESTORE)
return 0; return 0;
if (ovl) if (strncmp(upper, "overlay:", 8) == 0)
upper += 8; upper += 8;
else else if (strncmp(upper, "overlayfs:", 10) == 0)
upper += 10; upper += 10;
upper = strchr(upper, ':'); upper = strchr(upper, ':');
...@@ -485,10 +479,10 @@ int ovl_destroy(struct lxc_storage *orig) ...@@ -485,10 +479,10 @@ int ovl_destroy(struct lxc_storage *orig)
bool ovl_detect(const char *path) bool ovl_detect(const char *path)
{ {
if (!strncmp(path, "overlayfs:", 10)) if (!strncmp(path, "overlay:", 8))
return true; return true;
if (!strncmp(path, "overlay:", 8)) if (!strncmp(path, "overlayfs:", 10))
return true; return true;
return false; return false;
...@@ -521,18 +515,19 @@ int ovl_mount(struct lxc_storage *bdev) ...@@ -521,18 +515,19 @@ int ovl_mount(struct lxc_storage *bdev)
ERROR("Failed to allocate memory"); ERROR("Failed to allocate memory");
return -1; return -1;
} }
upper = dup;
lower = dup;
/* support multiple lower layers */ if (strncmp(dup, "overlay:", 8) == 0)
lower = strstr(dup, ":/"); lower += 8;
if (!lower) { else if (strncmp(dup, "overlayfs:", 10) == 0)
ERROR("Failed to detect \":/\" in string \"%s\"", dup); lower += 10;
free(dup); if (upper != lower)
return -22; upper = lower;
}
lower++; /* support multiple lower layers */
upper = lower; while ((tmp = strstr(upper, ":/"))) {
while ((tmp = strstr(++upper, ":/"))) { tmp++;
upper = tmp; upper = tmp;
} }
......
...@@ -268,10 +268,9 @@ struct lxc_storage *storage_get(const char *type) ...@@ -268,10 +268,9 @@ struct lxc_storage *storage_get(const char *type)
size_t i; size_t i;
struct lxc_storage *bdev; struct lxc_storage *bdev;
for (i = 0; i < numbdevs; i++) { for (i = 0; i < numbdevs; i++)
if (strcmp(bdevs[i].name, type) == 0) if (strcmp(bdevs[i].name, type) == 0)
break; break;
}
if (i == numbdevs) if (i == numbdevs)
return NULL; return NULL;
...@@ -284,7 +283,7 @@ struct lxc_storage *storage_get(const char *type) ...@@ -284,7 +283,7 @@ struct lxc_storage *storage_get(const char *type)
bdev->ops = bdevs[i].ops; bdev->ops = bdevs[i].ops;
bdev->type = bdevs[i].name; bdev->type = bdevs[i].name;
if (!strcmp(bdev->type, "aufs")) if (strcmp(bdev->type, "aufs") == 0)
WARN("The \"aufs\" driver will is deprecated and will soon be " WARN("The \"aufs\" driver will is deprecated and will soon be "
"removed. For similar functionality see the \"overlay\" " "removed. For similar functionality see the \"overlay\" "
"storage driver"); "storage driver");
...@@ -296,7 +295,7 @@ static struct lxc_storage *do_storage_create(const char *dest, const char *type, ...@@ -296,7 +295,7 @@ static struct lxc_storage *do_storage_create(const char *dest, const char *type,
const char *cname, const char *cname,
struct bdev_specs *specs) struct bdev_specs *specs)
{ {
int ret;
struct lxc_storage *bdev; struct lxc_storage *bdev;
if (!type) if (!type)
...@@ -306,7 +305,8 @@ static struct lxc_storage *do_storage_create(const char *dest, const char *type, ...@@ -306,7 +305,8 @@ static struct lxc_storage *do_storage_create(const char *dest, const char *type,
if (!bdev) if (!bdev)
return NULL; return NULL;
if (bdev->ops->create(bdev, dest, cname, specs) < 0) { ret = bdev->ops->create(bdev, dest, cname, specs);
if (ret < 0) {
storage_put(bdev); storage_put(bdev);
return NULL; return NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment