]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
add a lxc.rootfs.bdev option (not yet honored)
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Sat, 2 Apr 2016 20:41:24 +0000 (15:41 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Sat, 2 Apr 2016 20:41:24 +0000 (15:41 -0500)
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/bdev/bdev.c
src/lxc/bdev/bdev.h
src/lxc/conf.c
src/lxc/conf.h
src/lxc/confile.c

index 090b68579f80fd20d0de260f6a9282b889edd319..7514aaef246ee26509a471948afcc23b389110b1 100644 (file)
@@ -954,3 +954,18 @@ static bool unpriv_snap_allowed(struct bdev *b, const char *t, bool snap,
                return true;
        return false;
 }
+
+bool is_valid_bdev_type(const char *type)
+{
+       if (strcmp(type, "dir") == 0 ||
+                       strcmp(type, "btrfs") == 0 ||
+                       strcmp(type, "aufs") == 0 ||
+                       strcmp(type, "loop") == 0 ||
+                       strcmp(type, "lvm") == 0 ||
+                       strcmp(type, "nbd") == 0 ||
+                       strcmp(type, "ovl") == 0 ||
+                       strcmp(type, "rbd") == 0 ||
+                       strcmp(type, "zfs") == 0)
+               return true;
+       return false;
+}
index 91b9c8de0de9b36ce739eb8ff4950c931b241648..3f21e840435de10e2b51ee8752d71d53e6d54cc3 100644 (file)
@@ -146,4 +146,6 @@ bool rootfs_is_blockdev(struct lxc_conf *conf);
 bool attach_block_device(struct lxc_conf *conf);
 void detach_block_device(struct lxc_conf *conf);
 
+bool is_valid_bdev_type(const char *type);
+
 #endif // __LXC_BDEV_H
index 2f8338dad02f3c126d00c76e76be0da467f892bb..98cd38402fbd2b08ebc39b1663bc86cdb7c766c8 100644 (file)
@@ -4142,6 +4142,7 @@ void lxc_conf_free(struct lxc_conf *conf)
        free(conf->console.log_path);
        free(conf->console.path);
        free(conf->rootfs.mount);
+       free(conf->rootfs.bdev);
        free(conf->rootfs.options);
        free(conf->rootfs.path);
        free(conf->logfile);
index d3cd0b3274b6e8bd46d795bdf8e7d241bd7f8833..50516fdde863842ab67ef0a61a84accabed22214 100644 (file)
@@ -220,11 +220,13 @@ struct lxc_console {
  * @path       : the rootfs source (directory or device)
  * @mount      : where it is mounted
  * @options    : mount options
+ * @bev        : optional backing store type
  */
 struct lxc_rootfs {
        char *path;
        char *mount;
        char *options;
+       char *bdev;
 };
 
 /*
index 6fcfb1296dc17d7b754dc36e79b3b7a35e8355fa..15f2e7bec554b3e856ad955494961a5081d71deb 100644 (file)
@@ -42,6 +42,7 @@
 #include "parse.h"
 #include "config.h"
 #include "confile.h"
+#include "bdev/bdev.h"
 #include "utils.h"
 #include "log.h"
 #include "conf.h"
@@ -72,6 +73,7 @@ static int config_fstab(const char *, const char *, struct lxc_conf *);
 static int config_rootfs(const char *, const char *, struct lxc_conf *);
 static int config_rootfs_mount(const char *, const char *, struct lxc_conf *);
 static int config_rootfs_options(const char *, const char *, struct lxc_conf *);
+static int config_rootfs_bdev(const char *, const char *, struct lxc_conf *);
 static int config_pivotdir(const char *, const char *, struct lxc_conf *);
 static int config_utsname(const char *, const char *, struct lxc_conf *);
 static int config_hook(const char *, const char *, struct lxc_conf *lxc_conf);
@@ -130,6 +132,7 @@ static struct lxc_config_t config[] = {
        { "lxc.mount",                config_fstab                },
        { "lxc.rootfs.mount",         config_rootfs_mount         },
        { "lxc.rootfs.options",       config_rootfs_options       },
+       { "lxc.rootfs.bdev",          config_rootfs_bdev          },
        { "lxc.rootfs",               config_rootfs               },
        { "lxc.pivotdir",             config_pivotdir             },
        { "lxc.utsname",              config_utsname              },
@@ -1853,6 +1856,17 @@ static int config_rootfs_options(const char *key, const char *value,
        return config_string_item(&lxc_conf->rootfs.options, value);
 }
 
+static int config_rootfs_bdev(const char *key, const char *value,
+                              struct lxc_conf *lxc_conf)
+{
+       if (!is_valid_bdev_type(value)) {
+               ERROR("Bad bdev type for %s: %s", key, value);
+               return -1;
+       }
+
+       return config_string_item(&lxc_conf->rootfs.bdev, value);
+}
+
 static int config_pivotdir(const char *key, const char *value,
                           struct lxc_conf *lxc_conf)
 {