From 984bd6203a6ee88653ca80d0c12650162c635b1b Mon Sep 17 00:00:00 2001 From: Serge Hallyn Date: Sat, 2 Apr 2016 15:47:43 -0500 Subject: [PATCH] honor lxc.rootfs.bdev If that is specified, then we only use the specified backing store type. This can be useful if you know that lxc.rootfs is a directory type and you do not want lxc to waste time searching for zfs, btrfs, etc. Signed-off-by: Serge Hallyn --- src/lxc/bdev/bdev.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/lxc/bdev/bdev.c b/src/lxc/bdev/bdev.c index 7514aaef2..d57386c2c 100644 --- a/src/lxc/bdev/bdev.c +++ b/src/lxc/bdev/bdev.c @@ -201,7 +201,7 @@ static const struct bdev_type bdevs[] = { static const size_t numbdevs = sizeof(bdevs) / sizeof(struct bdev_type); /* helpers */ -static const struct bdev_type *bdev_query(const char *src); +static const struct bdev_type *bdev_query(struct lxc_conf *conf, const char *src); static struct bdev *bdev_get(const char *type); static struct bdev *do_bdev_create(const char *dest, const char *type, const char *cname, struct bdev_specs *specs); @@ -542,7 +542,7 @@ struct bdev *bdev_init(struct lxc_conf *conf, const char *src, const char *dst, if (!src) return NULL; - q = bdev_query(src); + q = bdev_query(conf, src); if (!q) return NULL; @@ -794,7 +794,7 @@ bool rootfs_is_blockdev(struct lxc_conf *conf) ret = stat(conf->rootfs.path, &st); if (ret == 0 && S_ISBLK(st.st_mode)) return true; - q = bdev_query(conf->rootfs.path); + q = bdev_query(conf, conf->rootfs.path); if (!q) return false; if (strcmp(q->name, "lvm") == 0 || @@ -841,9 +841,26 @@ static struct bdev *bdev_get(const char *type) return bdev; } -static const struct bdev_type *bdev_query(const char *src) +static const struct bdev_type *get_bdev_by_name(const char *name) { int i; + + for (i = 0; i < numbdevs; i++) { + if (strcmp(bdevs[i].name, name) == 0) + return &bdevs[i]; + } + + ERROR("Backing store %s unknown but not caught earlier\n", name); + return NULL; +} + +static const struct bdev_type *bdev_query(struct lxc_conf *conf, const char *src) +{ + int i; + + if (conf->rootfs.bdev) + return get_bdev_by_name(conf->rootfs.bdev); + for (i = 0; i < numbdevs; i++) { int r; r = bdevs[i].ops->detect(src); -- 2.47.2