diff --git a/docs/drvlxc.html.in b/docs/drvlxc.html.in index 5ce218d92a..47837d1a89 100644 --- a/docs/drvlxc.html.in +++ b/docs/drvlxc.html.in @@ -39,6 +39,23 @@ driver. On such kernels, it may be neccessary to unmount the blkio controller.

+

Environment setup for the container init

+ +

+When the container "init" process is started, it will be given several useful +environment variables. +

+ +
+
LIBVIRT_LXC_NAME
+
The name assigned to the container by libvirt
+
LIBVIRT_LXC_UUID
+
The UUID assigned to the container by libvirt
+
LIBVIRT_LXC_CMDLINE
+
The unparsed command line arguments specified in the container configuration
+
+ +

Example config version 1

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ab1249b704..f9007ce5a9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6834,6 +6834,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
                 goto error;
             }
         }
+        def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt);
     }
 
     if (STREQ(def->os.type, "xen") ||
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 787df9a3f6..69cea8e4df 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -116,6 +116,8 @@ static virCommandPtr lxcContainerBuildInitCmd(virDomainDefPtr vmDef)
     virCommandAddEnvString(cmd, "TERM=linux");
     virCommandAddEnvPair(cmd, "LIBVIRT_LXC_UUID", uuidstr);
     virCommandAddEnvPair(cmd, "LIBVIRT_LXC_NAME", vmDef->name);
+    if (vmDef->os.cmdline)
+        virCommandAddEnvPair(cmd, "LIBVIRT_LXC_CMDLINE", vmDef->os.cmdline);
 
     return cmd;
 }