]> git.proxmox.com Git - mirror_lxc.git/commitdiff
overlay: adapt to new config rootfs parser
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 28 Nov 2017 00:12:36 +0000 (01:12 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 28 Nov 2017 12:52:23 +0000 (13:52 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Adrian Reber <areber@redhat.com>
src/lxc/lxccontainer.c
src/lxc/storage/overlay.c
src/lxc/storage/storage.c

index 413dd375bd9a6d456de9fb9e0ab558188352c751..0fc10d0a547e54a146249fda26c035da0e808312 100644 (file)
@@ -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"))
                flags |= LXC_STORAGE_INTERNAL_OVERLAY_RESTORE;
-       rest = lxcapi_clone(snap, newname, c->config_path, flags,
-                       bdev->type, NULL, 0, NULL);
+       rest = lxcapi_clone(snap, newname, c->config_path, flags, bdev->type,
+                           NULL, 0, NULL);
        storage_put(bdev);
        if (rest && lxcapi_is_defined(rest))
                b = true;
index 0efefbee5f6b983156978f92e9efaf9586c5c631..81fd80f98d6f570557efcd166b682fed0660be61 100644 (file)
@@ -199,12 +199,11 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
                        return -22;
                }
 
-               nsrc = strchr(osrc, ':') + 1;
-               if ((nsrc != osrc + 8) && (nsrc != osrc + 10)) {
-                       ERROR("Detected \":\" in \"%s\" at wrong position", osrc);
-                       free(osrc);
-                       return -22;
-               }
+               nsrc = osrc;
+               if (strncmp(osrc, "overlay:", 8) == 0)
+                       nsrc += 8;
+               else if (strncmp(osrc, "overlayfs:", 10) == 0)
+                       nsrc += 10;
 
                odelta = strchr(nsrc, ':');
                if (!odelta) {
@@ -457,22 +456,17 @@ int ovl_create(struct lxc_storage *bdev, const char *dest, const char *n,
 
 int ovl_destroy(struct lxc_storage *orig)
 {
-       bool ovl;
        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
         * and cannot be removed when restoring from a snapshot.
         */
        if (orig->flags & LXC_STORAGE_INTERNAL_OVERLAY_RESTORE)
                return 0;
 
-       if (ovl)
+       if (strncmp(upper, "overlay:", 8) == 0)
                upper += 8;
-       else
+       else if (strncmp(upper, "overlayfs:", 10) == 0)
                upper += 10;
 
        upper = strchr(upper, ':');
@@ -485,10 +479,10 @@ int ovl_destroy(struct lxc_storage *orig)
 
 bool ovl_detect(const char *path)
 {
-       if (!strncmp(path, "overlayfs:", 10))
+       if (!strncmp(path, "overlay:", 8))
                return true;
 
-       if (!strncmp(path, "overlay:", 8))
+       if (!strncmp(path, "overlayfs:", 10))
                return true;
 
        return false;
@@ -521,18 +515,19 @@ int ovl_mount(struct lxc_storage *bdev)
                ERROR("Failed to allocate memory");
                return -1;
        }
+       upper = dup;
+       lower = dup;
 
-       /* support multiple lower layers */
-       lower = strstr(dup, ":/");
-       if (!lower) {
-               ERROR("Failed to detect \":/\" in string \"%s\"", dup);
-               free(dup);
-               return -22;
-       }
+       if (strncmp(dup, "overlay:", 8) == 0)
+               lower += 8;
+       else if (strncmp(dup, "overlayfs:", 10) == 0)
+               lower += 10;
+       if (upper != lower)
+               upper = lower;
 
-       lower++;
-       upper = lower;
-       while ((tmp = strstr(++upper, ":/"))) {
+       /* support multiple lower layers */
+       while ((tmp = strstr(upper, ":/"))) {
+               tmp++;
                upper = tmp;
        }
 
index 3c5d4c5a91df7c7e0f9c5940dac3245b95d84a3f..58940f44b6849194ef389364c2eb6234526f5d98 100644 (file)
@@ -268,10 +268,9 @@ struct lxc_storage *storage_get(const char *type)
        size_t i;
        struct lxc_storage *bdev;
 
-       for (i = 0; i < numbdevs; i++) {
+       for (i = 0; i < numbdevs; i++)
                if (strcmp(bdevs[i].name, type) == 0)
                        break;
-       }
 
        if (i == numbdevs)
                return NULL;
@@ -284,7 +283,7 @@ struct lxc_storage *storage_get(const char *type)
        bdev->ops = bdevs[i].ops;
        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 "
                     "removed. For similar functionality see the \"overlay\" "
                     "storage driver");
@@ -296,7 +295,7 @@ static struct lxc_storage *do_storage_create(const char *dest, const char *type,
                                             const char *cname,
                                             struct bdev_specs *specs)
 {
-
+       int ret;
        struct lxc_storage *bdev;
 
        if (!type)
@@ -306,7 +305,8 @@ static struct lxc_storage *do_storage_create(const char *dest, const char *type,
        if (!bdev)
                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);
                return NULL;
        }