[lxc-devel] [PATCH] Add lxc.disable_kmsg option

Alexander Vladimirov alexander.idkfa.vladimirov at gmail.com
Wed Mar 13 06:05:30 UTC 2013


Disables /dev/kmsg symlinking if set to 1.

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

diff --git a/doc/lxc.conf.sgml.in b/doc/lxc.conf.sgml.in
index b784025..b8078eb 100644
--- a/doc/lxc.conf.sgml.in
+++ b/doc/lxc.conf.sgml.in
@@ -554,6 +554,25 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
     </refsect2>
 
     <refsect2>
+      <title>Disable kmsg symlink</title>
+      <para>
+      Disables default behavior to create /dev/kmsg as symlink to /dev/console.
+      </para>
+      <variablelist>
+    <varlistentry>
+      <term>
+        <option>lxc.disable_kmsg</option>
+      </term>
+      <listitem>
+        <para>
+          Set this to 1 to disable /dev/kmsg symlinking.
+        </para>
+      </listitem>
+    </varlistentry>
+      </variablelist>
+    </refsect2>
+
+    <refsect2>
       <title>Mount points</title>
       <para>
 	The mount points section specifies the different places to be
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 9700c7a..9850d58 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -2768,8 +2768,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->disable_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 4c25970..e07c871 100644
--- a/src/lxc/conf.h
+++ b/src/lxc/conf.h
@@ -278,6 +278,7 @@ struct lxc_conf {
 	int maincmd_fd;
 	int autodev;  // if 1, mount and fill a /dev at start
 	int stopsignal; // signal used to stop container
+	int disable_kmsg; // disables /dev/kmsg symlinking
 	char *rcfile;	// Copy of the top level rcfile we read
 };
 
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index cd02b2e..da3a49d 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -90,6 +90,7 @@ static int config_includefile(const char *, const char *, struct lxc_conf *);
 static int config_network_nic(const char *, const char *, struct lxc_conf *);
 static int config_autodev(const char *, const char *, struct lxc_conf *);
 static int config_stopsignal(const char *, const char *, struct lxc_conf *);
+static int config_disable_kmsg(const char *, const char *, struct lxc_conf *);
 
 static struct lxc_config_t config[] = {
 
@@ -138,6 +139,7 @@ static struct lxc_config_t config[] = {
 	{ "lxc.include",              config_includefile          },
 	{ "lxc.autodev",              config_autodev              },
 	{ "lxc.stopsignal",           config_stopsignal           },
+	{ "lxc.disable_kmsg",         config_disable_kmsg         },
 };
 
 struct signame {
@@ -1049,6 +1051,16 @@ static int config_stopsignal(const char *key, const char *value,
 	return 0;
 }
 
+static int config_disable_kmsg(const char *key, const char *value,
+			 struct lxc_conf *lxc_conf)
+{
+	int v = atoi(value);
+
+	lxc_conf->disable_kmsg = v;
+
+	return 0;
+}
+
 static int config_cgroup(const char *key, const char *value,
 			 struct lxc_conf *lxc_conf)
 {
-- 
1.8.1.5





More information about the lxc-devel mailing list