]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
add lxc.console.logpath
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Fri, 8 Aug 2014 18:34:38 +0000 (18:34 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 8 Aug 2014 18:37:29 +0000 (14:37 -0400)
logpath has been supported through lxc-start command line, but not
through the API.  Since the lxc.console is now required to be a device,
support lxc.console.logfile to be a simple file to which console output
will be logged.

clear_config_item is not supported, as it isn't for lxc.console, bc
you can do 'lxc.console.logfile =' to clear it.

(This patch is for stable-1.0)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
doc/lxc.container.conf.sgml.in
src/lxc/conf.c
src/lxc/confile.c

index 0cf16391a9e754cfe0868644fca2623cbb87f327..88a5f055553fa6a5f2c1fb5bb42b1c8991c283fc 100644 (file)
@@ -536,13 +536,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
       <variablelist>
        <varlistentry>
          <term>
-           <option>lxc.console</option>
+           <option>lxc.console.logfile</option>
          </term>
          <listitem>
            <para>
              Specify a path to a file where the console output will
-             be written. The keyword 'none' will simply disable the
-             console. This is dangerous once if have a rootfs with a
+             be written.
+           </para>
+         </listitem>
+       </varlistentry>
+       <varlistentry>
+         <term>
+           <option>lxc.console</option>
+         </term>
+         <listitem>
+           <para>
+             Specify a path to a device to which the console will be
+             attached.  The keyword 'none' will simply disable the
+             console.  This is dangerous once if have a rootfs with a
              console device file where the application can write, the
              messages will fall in the host.
            </para>
index a90c57ccd9252fcda60ff497a3b7554762fb1185..7fb6e6f5d1d558db8b3bd348d2354214b07ac927 100644 (file)
@@ -4390,6 +4390,8 @@ void lxc_conf_free(struct lxc_conf *conf)
 {
        if (!conf)
                return;
+       if (conf->console.log_path)
+               free(conf->console.log_path);
        if (conf->console.path)
                free(conf->console.path);
        if (conf->rootfs.mount)
index 4c3338d09b8ebcb9c3bff7e3ee9f1864e0370342..dcd95189a85d886f6fc2028748fed371646fb1f6 100644 (file)
@@ -88,6 +88,7 @@ static int config_network_ipv6_gateway(const char *, const char *, struct lxc_co
 static int config_cap_drop(const char *, const char *, struct lxc_conf *);
 static int config_cap_keep(const char *, const char *, struct lxc_conf *);
 static int config_console(const char *, const char *, struct lxc_conf *);
+static int config_console_logfile(const char *, const char *, struct lxc_conf *);
 static int config_seccomp(const char *, const char *, struct lxc_conf *);
 static int config_includefile(const char *, const char *, struct lxc_conf *);
 static int config_network_nic(const char *, const char *, struct lxc_conf *);
@@ -142,6 +143,7 @@ static struct lxc_config_t config[] = {
        { "lxc.network.",             config_network_nic          },
        { "lxc.cap.drop",             config_cap_drop             },
        { "lxc.cap.keep",             config_cap_keep             },
+       { "lxc.console.logfile",      config_console_logfile      },
        { "lxc.console",              config_console              },
        { "lxc.seccomp",              config_seccomp              },
        { "lxc.include",              config_includefile          },
@@ -1564,6 +1566,12 @@ static int config_console(const char *key, const char *value,
        return config_path_item(&lxc_conf->console.path, value);
 }
 
+static int config_console_logfile(const char *key, const char *value,
+                         struct lxc_conf *lxc_conf)
+{
+       return config_path_item(&lxc_conf->console.log_path, value);
+}
+
 static int config_includefile(const char *key, const char *value,
                          struct lxc_conf *lxc_conf)
 {
@@ -2160,6 +2168,8 @@ int lxc_get_config_item(struct lxc_conf *c, const char *key, char *retv,
                return lxc_get_cgroup_entry(c, retv, inlen, key + 11);
        else if (strcmp(key, "lxc.utsname") == 0)
                v = c->utsname ? c->utsname->nodename : NULL;
+       else if (strcmp(key, "lxc.console.logfile") == 0)
+               v = c->console.log_path;
        else if (strcmp(key, "lxc.console") == 0)
                v = c->console.path;
        else if (strcmp(key, "lxc.rootfs.mount") == 0)
@@ -2410,6 +2420,8 @@ void write_config(FILE *fout, struct lxc_conf *c)
        }
        if (c->console.path)
                fprintf(fout, "lxc.console = %s\n", c->console.path);
+       if (c->console.log_path)
+               fprintf(fout, "lxc.console.logfile = %s\n", c->console.log_path);
        if (c->rootfs.path)
                fprintf(fout, "lxc.rootfs = %s\n", c->rootfs.path);
        if (c->rootfs.mount && strcmp(c->rootfs.mount, LXCROOTFSMOUNT) != 0)