lxccontainer: various container creation fixes

This is beneficial for LXD as well. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com> Signed-off-by: 's avatarAdrian Reber <areber@redhat.com>
parent 8a388ed4
...@@ -559,20 +559,21 @@ on_error_put_orig: ...@@ -559,20 +559,21 @@ on_error_put_orig:
struct lxc_storage *storage_create(const char *dest, const char *type, struct lxc_storage *storage_create(const char *dest, const char *type,
const char *cname, struct bdev_specs *specs) const char *cname, struct bdev_specs *specs)
{ {
int ret;
struct lxc_storage *bdev; struct lxc_storage *bdev;
char *best_options[] = {"btrfs", "zfs", "lvm", "dir", "rbd", NULL}; char *best_options[] = {"btrfs", "zfs", "lvm", "dir", "rbd", NULL};
if (!type) if (!type)
return do_storage_create(dest, "dir", cname, specs); return do_storage_create(dest, "dir", cname, specs);
if (strcmp(type, "best") == 0) { ret = strcmp(type, "best");
if (ret == 0) {
int i; int i;
/* Try for the best backing store type, according to our /* Try for the best backing store type, according to our
* opinionated preferences. * opinionated preferences.
*/ */
for (i = 0; best_options[i]; i++) { for (i = 0; best_options[i]; i++) {
bdev = do_storage_create(dest, best_options[i], cname, bdev = do_storage_create(dest, best_options[i], cname, specs);
specs);
if (bdev) if (bdev)
return bdev; return bdev;
} }
...@@ -581,12 +582,16 @@ struct lxc_storage *storage_create(const char *dest, const char *type, ...@@ -581,12 +582,16 @@ struct lxc_storage *storage_create(const char *dest, const char *type,
} }
/* -B lvm,dir */ /* -B lvm,dir */
if (strchr(type, ',') != NULL) { if (strchr(type, ',')) {
char *dup = alloca(strlen(type) + 1), *saveptr = NULL, *token; char *dup, *token;
char *saveptr = NULL;
dup = alloca(strlen(type) + 1);
strcpy(dup, type); strcpy(dup, type);
for (token = strtok_r(dup, ",", &saveptr); token; for (token = strtok_r(dup, ",", &saveptr); token;
token = strtok_r(NULL, ",", &saveptr)) { token = strtok_r(NULL, ",", &saveptr)) {
if ((bdev = do_storage_create(dest, token, cname, specs))) bdev = do_storage_create(dest, token, cname, specs);
if (bdev)
return bdev; return bdev;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment