[lxc-devel] [PATCH] Make /dev/kmsg symlinking optional, add lxc.kmsg option

Alexander Vladimirov alexander.idkfa.vladimirov at gmail.com
Mon Mar 11 05:15:18 UTC 2013


Had this changeset hanging around for some time, maybe this would be useful
until some better solution come up.

Signed-off-by: Alexander Vladimirov <alexander.idkfa.vladimirov at gmail.com>
---
 src/lxc/conf.c    |  6 ++++--
 src/lxc/conf.h    |  1 +
 src/lxc/confile.c | 12 ++++++++++++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index add3c74..1600e73 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -2746,8 +2746,10 @@ int lxc_setup(const char *name, struct lxc_conf *lxc_conf)
 		return -1;
 	}
 
-	if (setup_kmsg(&lxc_conf->rootfs, &lxc_conf->console))  // don't fail
-		ERROR("failed to setup kmsg for '%s'", name);
+	if (lxc_conf->kmsg) {
+		if (setup_kmsg(&lxc_conf->rootfs, &lxc_conf->console))  // don't fail
+			ERROR("failed to setup kmsg for '%s'", name);
+	}
 
 	if (setup_tty(&lxc_conf->rootfs, &lxc_conf->tty_info, lxc_conf->ttydir)) {
 		ERROR("failed to setup the ttys for '%s'", name);
diff --git a/src/lxc/conf.h b/src/lxc/conf.h
index f20fb2f..652a1be 100644
--- a/src/lxc/conf.h
+++ b/src/lxc/conf.h
@@ -277,6 +277,7 @@ struct lxc_conf {
 #endif
 	int maincmd_fd;
 	int autodev;  // if 1, mount and fill a /dev at start
+	int kmsg;  // if 1, create /dev/kmsg symlink
 	char *rcfile;	// Copy of the top level rcfile we read
 };
 
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index d350f01..87f3ae1 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -54,6 +54,7 @@ static int config_personality(const char *, const char *, struct lxc_conf *);
 static int config_pts(const char *, const char *, struct lxc_conf *);
 static int config_tty(const char *, const char *, struct lxc_conf *);
 static int config_ttydir(const char *, const char *, struct lxc_conf *);
+static int config_kmsg(const char *, const char *, struct lxc_conf *);
 #if HAVE_APPARMOR
 static int config_aa_profile(const char *, const char *, struct lxc_conf *);
 #endif
@@ -94,6 +95,7 @@ static struct lxc_config_t config[] = {
 	{ "lxc.pts",                  config_pts                  },
 	{ "lxc.tty",                  config_tty                  },
 	{ "lxc.devttydir",            config_ttydir               },
+	{ "lxc.kmsg",                 config_kmsg                 },
 #if HAVE_APPARMOR
 	{ "lxc.aa_profile",            config_aa_profile          },
 #endif
@@ -902,6 +904,16 @@ static int config_ttydir(const char *key, const char *value,
 	return 0;
 }
 
+static int config_kmsg(const char *key, const char *value,
+			  struct lxc_conf *lxc_conf)
+{
+	int v = atoi(value);
+
+	lxc_conf->kmsg = v;
+
+	return 0;
+}
+
 #if HAVE_APPARMOR
 static int config_aa_profile(const char *key, const char *value,
 			     struct lxc_conf *lxc_conf)
-- 
1.8.1.5





More information about the lxc-devel mailing list