Since LXC version 1.0.2, it lost support for outputting console logs
into a file until the lxc.console.logfile parameter has introduced in
1.0.6.
We have to check the version of LXC and should disable specifying
lxc.console.logfile parameter in versions less than 1.0.6.

Signed-off-by: Yuto KAWAMURA(kawamuray) <[email protected]>
---
 lib/hypervisor/hv_lxc.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/hypervisor/hv_lxc.py b/lib/hypervisor/hv_lxc.py
index 3f11a3d..ad7c3dd 100644
--- a/lib/hypervisor/hv_lxc.py
+++ b/lib/hypervisor/hv_lxc.py
@@ -512,10 +512,20 @@ class LXCHypervisor(hv_base.BaseHypervisor):
     lxc_ttys = instance.hvparams[constants.HV_LXC_TTY]
     if lxc_ttys: # if it is the number greater than 0
       out.append("lxc.tty = %s" % lxc_ttys)
+
     # console log file
-    console_log_path = self._InstanceConsoleLogFilePath(instance.name)
-    self._CreateBlankFile(console_log_path, constants.SECURE_FILE_MODE)
-    out.append("lxc.console = %s" % console_log_path)
+    # Since the following patch has applied, we lost the console log file 
output
+    # until the lxc.console.logfile parameter has supported in 1.0.6.
+    # https://
+    # lists.linuxcontainers.org/pipermail/lxc-devel/2014-March/008470.html
+    lxc_version = self._GetLXCVersion()
+    if lxc_version >= LXCVersion("1.0.6"):
+      console_log_path = self._InstanceConsoleLogFilePath(instance.name)
+      self._CreateBlankFile(console_log_path, constants.SECURE_FILE_MODE)
+      out.append("lxc.console.logfile = %s" % console_log_path)
+    else:
+      logging.warn("Console log file is not supported in LXC version %s,"
+                   " disabling.", lxc_version)
 
     # root FS
     out.append("lxc.rootfs = %s" % sda_dev_path)
-- 
1.8.5.5

Reply via email to