[lxc-devel] [lxc/master] rootfs.bdev_type: implement get and clear

hallyn on Github lxc-bot at linuxcontainers.org
Sun Apr 3 01:44:53 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 453 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160403/af187211/attachment.bin>
-------------- next part --------------
From 6a21d4aeacea769eacd9c8b96398733dae160985 Mon Sep 17 00:00:00 2001
From: Serge Hallyn <serge.hallyn at ubuntu.com>
Date: Sat, 2 Apr 2016 20:43:35 -0500
Subject: [PATCH] rootfs.bdev_type: implement get and clear

clear is just set(x, ""), but before this patch that didn't work bc
"" is nota valid bdev type.

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 src/lxc/confile.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 64cce02..23107a1 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -1859,6 +1859,10 @@ static int config_rootfs_options(const char *key, const char *value,
 static int config_rootfs_bdev_type(const char *key, const char *value,
 			       struct lxc_conf *lxc_conf)
 {
+	if (strlen(value) == 0) {
+		free(lxc_conf->rootfs.bdev_type);
+		lxc_conf->rootfs.bdev_type = NULL;
+	}
 	if (!is_valid_bdev_type(value)) {
 		ERROR("Bad bdev type for %s: %s", key, value);
 		return -1;
@@ -2488,6 +2492,8 @@ int lxc_get_config_item(struct lxc_conf *c, const char *key, char *retv,
 		v = c->console.path;
 	else if (strcmp(key, "lxc.rootfs.mount") == 0)
 		v = c->rootfs.mount;
+	else if (strcmp(key, "lxc.rootfs.bdev") == 0)
+		v = c->rootfs.bdev_type;
 	else if (strcmp(key, "lxc.rootfs.options") == 0)
 		v = c->rootfs.options;
 	else if (strcmp(key, "lxc.rootfs") == 0)


More information about the lxc-devel mailing list