Commit 4d772b5d by Serge Hallyn Committed by Stéphane Graber

Do not allow snapshots of LVM backed containers

They don't work right now, so until we fix that, don't allow it. (This patch is for stable-1.0) Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 7a8bee8a
...@@ -520,6 +520,7 @@ static const struct bdev_ops dir_ops = { ...@@ -520,6 +520,7 @@ static const struct bdev_ops dir_ops = {
.destroy = &dir_destroy, .destroy = &dir_destroy,
.create = &dir_create, .create = &dir_create,
.can_snapshot = false, .can_snapshot = false,
.can_backup = true,
}; };
...@@ -784,6 +785,7 @@ static const struct bdev_ops zfs_ops = { ...@@ -784,6 +785,7 @@ static const struct bdev_ops zfs_ops = {
.destroy = &zfs_destroy, .destroy = &zfs_destroy,
.create = &zfs_create, .create = &zfs_create,
.can_snapshot = true, .can_snapshot = true,
.can_backup = true,
}; };
// //
...@@ -1179,6 +1181,7 @@ static const struct bdev_ops lvm_ops = { ...@@ -1179,6 +1181,7 @@ static const struct bdev_ops lvm_ops = {
.destroy = &lvm_destroy, .destroy = &lvm_destroy,
.create = &lvm_create, .create = &lvm_create,
.can_snapshot = true, .can_snapshot = true,
.can_backup = false,
}; };
/* /*
...@@ -1858,6 +1861,7 @@ static const struct bdev_ops btrfs_ops = { ...@@ -1858,6 +1861,7 @@ static const struct bdev_ops btrfs_ops = {
.destroy = &btrfs_destroy, .destroy = &btrfs_destroy,
.create = &btrfs_create, .create = &btrfs_create,
.can_snapshot = true, .can_snapshot = true,
.can_backup = true,
}; };
// //
...@@ -2129,6 +2133,7 @@ static const struct bdev_ops loop_ops = { ...@@ -2129,6 +2133,7 @@ static const struct bdev_ops loop_ops = {
.destroy = &loop_destroy, .destroy = &loop_destroy,
.create = &loop_create, .create = &loop_create,
.can_snapshot = false, .can_snapshot = false,
.can_backup = true,
}; };
// //
...@@ -2426,6 +2431,7 @@ static const struct bdev_ops overlayfs_ops = { ...@@ -2426,6 +2431,7 @@ static const struct bdev_ops overlayfs_ops = {
.destroy = &overlayfs_destroy, .destroy = &overlayfs_destroy,
.create = &overlayfs_create, .create = &overlayfs_create,
.can_snapshot = true, .can_snapshot = true,
.can_backup = true,
}; };
// //
...@@ -2703,6 +2709,7 @@ static const struct bdev_ops aufs_ops = { ...@@ -2703,6 +2709,7 @@ static const struct bdev_ops aufs_ops = {
.destroy = &aufs_destroy, .destroy = &aufs_destroy,
.create = &aufs_create, .create = &aufs_create,
.can_snapshot = true, .can_snapshot = true,
.can_backup = true,
}; };
...@@ -2769,6 +2776,9 @@ struct bdev *bdev_init(const char *src, const char *dst, const char *mntopts) ...@@ -2769,6 +2776,9 @@ struct bdev *bdev_init(const char *src, const char *dst, const char *mntopts)
struct bdev *bdev; struct bdev *bdev;
const struct bdev_type *q; const struct bdev_type *q;
if (!src)
return NULL;
q = bdev_query(src); q = bdev_query(src);
if (!q) if (!q)
return NULL; return NULL;
...@@ -2855,6 +2865,18 @@ bool bdev_is_dir(const char *path) ...@@ -2855,6 +2865,18 @@ bool bdev_is_dir(const char *path)
return ret; return ret;
} }
bool bdev_can_backup(struct lxc_conf *conf)
{
struct bdev *bdev = bdev_init(conf->rootfs.path, NULL, NULL);
bool ret;
if (!bdev)
return false;
ret = bdev->ops->can_backup;
bdev_put(bdev);
return ret;
}
/* /*
* is an unprivileged user allowed to make this kind of snapshot * is an unprivileged user allowed to make this kind of snapshot
*/ */
......
...@@ -48,6 +48,7 @@ struct bdev_ops { ...@@ -48,6 +48,7 @@ struct bdev_ops {
const char *cname, const char *oldpath, const char *lxcpath, const char *cname, const char *oldpath, const char *lxcpath,
int snap, uint64_t newsize, struct lxc_conf *conf); int snap, uint64_t newsize, struct lxc_conf *conf);
bool can_snapshot; bool can_snapshot;
bool can_backup;
}; };
/* /*
...@@ -71,6 +72,7 @@ struct bdev { ...@@ -71,6 +72,7 @@ struct bdev {
char *overlay_getlower(char *p); char *overlay_getlower(char *p);
bool bdev_is_dir(const char *path); bool bdev_is_dir(const char *path);
bool bdev_can_backup(struct lxc_conf *conf);
/* /*
* Instantiate a bdev object. The src is used to determine which blockdev * Instantiate a bdev object. The src is used to determine which blockdev
......
...@@ -2865,6 +2865,12 @@ static int lxcapi_snapshot(struct lxc_container *c, const char *commentfile) ...@@ -2865,6 +2865,12 @@ static int lxcapi_snapshot(struct lxc_container *c, const char *commentfile)
if (!c || !lxcapi_is_defined(c)) if (!c || !lxcapi_is_defined(c))
return -1; return -1;
if (!bdev_can_backup(c->lxc_conf)) {
ERROR("%s's backing store cannot be backed up.", c->name);
ERROR("Your container must use another backing store type.");
return -1;
}
// /var/lib/lxc -> /var/lib/lxcsnaps \0 // /var/lib/lxc -> /var/lib/lxcsnaps \0
ret = snprintf(snappath, MAXPATHLEN, "%ssnaps/%s", c->config_path, c->name); ret = snprintf(snappath, MAXPATHLEN, "%ssnaps/%s", c->config_path, c->name);
if (ret < 0 || ret >= MAXPATHLEN) if (ret < 0 || ret >= MAXPATHLEN)
......
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