[lxc-devel] [PATCH 4/6] Add bdev_destroy() to bdev.c and bdev.h static do_bdev_destroy() in lxccontainer.c becomes public bdev_destroy()

Christian Brauner christianvanbrauner at gmail.com
Sun Sep 6 08:38:19 UTC 2015


Signed-off-by: Christian Brauner <christianvanbrauner at gmail.com>

 100.0% src/lxc/
diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c
index ada3958..475d878 100644
--- a/src/lxc/bdev.c
+++ b/src/lxc/bdev.c
@@ -3614,3 +3614,21 @@ bool rootfs_is_blockdev(struct lxc_conf *conf)
 		return true;
 	return false;
 }
+
+bool bdev_destroy(struct lxc_conf *conf)
+{
+	struct bdev *r;
+	bool ret = false;
+
+	r = bdev_init(conf, conf->rootfs.path, conf->rootfs.mount, NULL);
+	if (!r)
+		return ret;
+
+	if (r->ops->destroy(r) < 0)
+		return ret;
+	bdev_put(r);
+
+	ret = true;
+	return ret;
+}
+
diff --git a/src/lxc/bdev.h b/src/lxc/bdev.h
index 428b3b7..b034bcb 100644
--- a/src/lxc/bdev.h
+++ b/src/lxc/bdev.h
@@ -123,6 +123,7 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
 struct bdev *bdev_create(const char *dest, const char *type,
 			const char *cname, struct bdev_specs *specs);
 void bdev_put(struct bdev *bdev);
+bool bdev_destroy(struct lxc_conf *conf);
 
 /*
  * these are really for qemu-nbd support, as container shutdown
-- 
2.5.1



More information about the lxc-devel mailing list