]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
storage: make storage_dir() smart
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 28 Nov 2017 10:44:49 +0000 (11:44 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 15 Dec 2017 11:31:10 +0000 (12:31 +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/storage.c
src/lxc/storage/storage.h

index afa8b8b7b59266dcc5348fdeb0c547a1072b601a..d86c3307168fc673a7479e4739cbf6d5d67d6a35 100644 (file)
@@ -3740,7 +3740,7 @@ static int do_lxcapi_snapshot(struct lxc_container *c, const char *commentfile)
         */
        flags = LXC_CLONE_SNAPSHOT | LXC_CLONE_KEEPMACADDR | LXC_CLONE_KEEPNAME |
                LXC_CLONE_KEEPBDEVTYPE | LXC_CLONE_MAYBE_SNAPSHOT;
-       if (storage_is_dir(c->lxc_conf, c->lxc_conf->rootfs.path)) {
+       if (storage_is_dir(c->lxc_conf)) {
                ERROR("Snapshot of directory-backed container requested.");
                ERROR("Making a copy-clone.  If you do want snapshots, then");
                ERROR("please create an aufs or overlay clone first, snapshot that");
index 58940f44b6849194ef389364c2eb6234526f5d98..8d5b39907f9b09d534fd3901b306403df86e68f4 100644 (file)
@@ -650,12 +650,16 @@ struct lxc_storage *storage_init(struct lxc_conf *conf, const char *src,
        return bdev;
 }
 
-bool storage_is_dir(struct lxc_conf *conf, const char *path)
+bool storage_is_dir(struct lxc_conf *conf)
 {
        struct lxc_storage *orig;
+       char *type = conf->rootfs.bdev_type;
        bool bret = false;
 
-       orig = storage_init(conf, path, NULL, NULL);
+       if (type)
+               return (strcmp(type, "dir") == 0);
+
+       orig = storage_init(conf, conf->lxc_rootfs.path, NULL, NULL);
        if (!orig)
                return bret;
 
index 7156543e961f6a3d5eb62ee941fc76c3ec23a2f7..da59adf9552aa88de273ba1559a9be852b001eb6 100644 (file)
@@ -109,7 +109,19 @@ struct lxc_storage {
        int flags;
 };
 
-extern bool storage_is_dir(struct lxc_conf *conf, const char *path);
+/**
+ * storage_is_dir : Check whether the roots is a directory. This function will
+ *                  trust the config file. If the config file key
+ *                  lxc.rootfs.path is set to <storage type>:<container path>
+ *                  the confile parser will have split this into <storage type>
+ *                  and <container path> and set the <bdev_type> member in the
+ *                  lxc_rootfs struct to <storage type> and the <path> member
+ *                  will be set to a clean <container path> without the <storage
+ *                  type> prefix. This is the new, clean way of handling storage
+ *                  type specifications.  If the <storage type> prefix is not
+ *                  detected liblxc will try to detect the storage type.
+ */
+extern bool storage_is_dir(struct lxc_conf *conf);
 extern bool storage_can_backup(struct lxc_conf *conf);
 
 /* Instantiate a lxc_storage object. The src is used to determine which blockdev