]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
storage: pass down storage type
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 27 Nov 2017 23:57:09 +0000 (00:57 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 15 Dec 2017 11:30:54 +0000 (12:30 +0100)
The configuration file parser now already detects the storage type so spare the
work and pass it down to the storage drivers.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Adrian Reber <areber@redhat.com>
src/lxc/storage/storage.c

index 2a91aab679f4f06cb596076ac67691035d138df1..3c5d4c5a91df7c7e0f9c5940dac3245b95d84a3f 100644 (file)
@@ -213,17 +213,27 @@ static const struct lxc_storage_type bdevs[] = {
 
 static const size_t numbdevs = sizeof(bdevs) / sizeof(struct lxc_storage_type);
 
-static const struct lxc_storage_type *get_storage_by_name(const char *name)
+static const struct lxc_storage_type *get_storage_by_name(const char *name,
+                                                         const char *type)
 {
+       int ret;
        size_t i, cmplen;
 
-       cmplen = strcspn(name, ":");
+       if (type)
+               cmplen = strlen(type);
+       else
+               cmplen = strcspn(name, ":");
        if (cmplen == 0)
                return NULL;
 
-       for (i = 0; i < numbdevs; i++)
-               if (strncmp(bdevs[i].name, name, cmplen) == 0)
+       for (i = 0; i < numbdevs; i++) {
+               if (type)
+                       ret = strncmp(bdevs[i].name, type, cmplen);
+               else
+                       ret = strncmp(bdevs[i].name, name, cmplen);
+               if (ret == 0)
                        break;
+       }
 
        if (i == numbdevs)
                return NULL;
@@ -238,7 +248,7 @@ const struct lxc_storage_type *storage_query(struct lxc_conf *conf,
        size_t i;
        const struct lxc_storage_type *bdev;
 
-       bdev = get_storage_by_name(src);
+       bdev = get_storage_by_name(src, conf->rootfs.bdev_type);
        if (bdev)
                return bdev;