[lxc-devel] [lxc/master] conf: expand shmounts lxc.mount.auto option

brauner on Github lxc-bot at linuxcontainers.org
Tue Oct 30 13:31:58 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 505 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181030/e82f1881/attachment.bin>
-------------- next part --------------
From 866a75b922aa938d187a010e0ef98cc866089801 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 30 Oct 2018 14:16:58 +0100
Subject: [PATCH] conf: expand shmounts lxc.mount.auto option

Allow users to specify a path in the contain they want to user. This
will help LXD.

Needed-by: https://github.com/lxc/lxd/issues/5227

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/confile.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index e1f4266b6..4e8ec9807 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -1788,18 +1788,24 @@ static int set_config_mount_auto(const char *key, const char *value,
 		lxc_conf->auto_mounts |= allowed_auto_mounts[i].flag;
 
 		if (is_shmounts) {
-			lxc_conf->shmount.path_host = strdup(token + STRLITERALLEN("shmounts:"));
-			if (!lxc_conf->shmount.path_host) {
+			char *slide = token + STRLITERALLEN("shmounts:");
+
+			if (*slide == '\0') {
 				SYSERROR("Failed to copy shmounts host path");
 				goto on_error;
 			}
 
-			if (strcmp(lxc_conf->shmount.path_host, "") == 0) {
-				ERROR("Invalid shmounts path: empty");
+			lxc_conf->shmount.path_host = strdup(slide);
+			if (!lxc_conf->shmount.path_host) {
+				SYSERROR("Failed to copy shmounts host path");
 				goto on_error;
 			}
 
-			lxc_conf->shmount.path_cont = strdup("/dev/.lxc-mounts");
+			slide = strchr(slide, ':');
+			if (!slide || *(++slide) == '\0')
+				slide = "/dev/.lxc-mounts";
+
+			lxc_conf->shmount.path_cont = strdup(slide);
 			if(!lxc_conf->shmount.path_cont) {
 				SYSERROR("Failed to copy shmounts container path");
 				goto on_error;


More information about the lxc-devel mailing list