LXC: add lxc.console to the generated lxc.conf file
authorBalazs Lecz <leczb@google.com>
Mon, 5 Jul 2010 14:48:39 +0000 (14:48 +0000)
committerBalazs Lecz <leczb@google.com>
Wed, 7 Jul 2010 13:36:26 +0000 (13:36 +0000)
Signed-off-by: Balazs Lecz <leczb@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/constants.py
lib/hypervisor/hv_lxc.py

index a7570c9..5ff50fc 100644 (file)
@@ -97,6 +97,7 @@ DISK_LINKS_DIR = RUN_GANETI_DIR + "/instance-disks"
 RUN_DIRS_MODE = 0775
 SOCKET_DIR = RUN_GANETI_DIR + "/socket"
 SECURE_DIR_MODE = 0700
+SECURE_FILE_MODE = 0600
 SOCKET_DIR_MODE = 0750
 CRYPTO_KEYS_DIR = RUN_GANETI_DIR + "/crypto"
 CRYPTO_KEYS_DIR_MODE = SECURE_DIR_MODE
index 81e416e..c7c6f24 100644 (file)
@@ -164,8 +164,17 @@ class LXCHypervisor(hv_base.BaseHypervisor):
 
     # separate pseudo-TTY instances
     out.append("lxc.pts = 255")
-    # standard TTYs/console
+    # standard TTYs
     out.append("lxc.tty = 6")
+    # console log file
+    console_log = utils.PathJoin(self._ROOT_DIR, instance.name + ".console")
+    try:
+      utils.WriteFile(console_log, data="", mode=constants.SECURE_FILE_MODE)
+    except EnvironmentError, err:
+      raise errors.HypervisorError("Creating console log file %s for"
+                                   " instance %s failed: %s" %
+                                   (console_log, instance.name, err))
+    out.append("lxc.console = %s" % console_log)
 
     # root FS
     out.append("lxc.rootfs = %s" % root_dir)