This patch adds new hvparam "lxc_tty" to the LXC hypervisor.
This parameter specifies the number of ttys(actually ptys) should be
allocated for the container.
The value of lxc.tty should be configurable because in some cases, we
want to disable pts instance allocation for the LXC container.

Signed-off-by: Yuto KAWAMURA(kawamuray) <[email protected]>
---
 lib/hypervisor/hv_lxc.py |  5 ++++-
 man/gnt-instance.rst     | 11 +++++++++++
 src/Ganeti/Constants.hs  |  5 +++++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/lib/hypervisor/hv_lxc.py b/lib/hypervisor/hv_lxc.py
index 9678b2b..d988163 100644
--- a/lib/hypervisor/hv_lxc.py
+++ b/lib/hypervisor/hv_lxc.py
@@ -69,6 +69,7 @@ class LXCHypervisor(hv_base.BaseHypervisor):
     constants.HV_LXC_DEVICES: hv_base.NO_CHECK,
     constants.HV_LXC_DROP_CAPABILITIES: hv_base.NO_CHECK,
     constants.HV_LXC_EXTRA_CONFIG: hv_base.NO_CHECK,
+    constants.HV_LXC_TTY: hv_base.REQ_NONNEGATIVE_INT_CHECK,
     constants.HV_LXC_STARTUP_WAIT: hv_base.OPT_NONNEGATIVE_INT_CHECK,
     }
 
@@ -445,7 +446,9 @@ class LXCHypervisor(hv_base.BaseHypervisor):
     # separate pseudo-TTY instances
     out.append("lxc.pts = 255")
     # standard TTYs
-    out.append("lxc.tty = 6")
+    lxc_ttys = instance.hvparams[constants.HV_LXC_TTY]
+    if lxc_ttys: # if it is the number grater than 0
+      out.append("lxc.tty = %s" % lxc_ttys)
     # console log file
     console_log = utils.PathJoin(self._ROOT_DIR, instance.name + ".console")
     try:
diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst
index d5cfe13..43c0a3a 100644
--- a/man/gnt-instance.rst
+++ b/man/gnt-instance.rst
@@ -951,6 +951,17 @@ lxc\_extra\_config
 
     This parameter is not set by default.
 
+lxc\_tty
+    Valid for the LXC hypervisor.
+
+    This option specifies the number of ttys(actually ptys) should be
+    allocated for the LXC container.
+    You can disable pty devices allocation for the LXC container by
+    setting this parameter to 0, but you can't use
+    **gnt-instance console** in this case.
+
+    It is set to ``6`` by default.
+
 The ``-O (--os-parameters)`` option allows customisation of the OS
 parameters. The actual parameter names and values depend on the OS being
 used, but the syntax is the same key=value. For example, setting a
diff --git a/src/Ganeti/Constants.hs b/src/Ganeti/Constants.hs
index 848085e..8a93096 100644
--- a/src/Ganeti/Constants.hs
+++ b/src/Ganeti/Constants.hs
@@ -1701,6 +1701,9 @@ hvLxcDropCapabilities = "lxc_drop_capabilities"
 hvLxcExtraConfig :: String
 hvLxcExtraConfig = "lxc_extra_config"
 
+hvLxcTty :: String
+hvLxcTty = "lxc_tty"
+
 hvMemPath :: String
 hvMemPath = "mem_path"
 
@@ -1867,6 +1870,7 @@ hvsParameterTypes = Map.fromList
   , (hvLxcDevices,                      VTypeString)
   , (hvLxcDropCapabilities,             VTypeString)
   , (hvLxcExtraConfig,                  VTypeString)
+  , (hvLxcTty,                          VTypeInt)
   , (hvLxcStartupWait,                  VTypeInt)
   , (hvMemPath,                         VTypeString)
   , (hvMigrationBandwidth,              VTypeInt)
@@ -3952,6 +3956,7 @@ hvcDefaults =
           , (hvLxcDevices,          PyValueEx lxcDevicesDefault)
           , (hvLxcDropCapabilities, PyValueEx lxcDropCapabilitiesDefault)
           , (hvLxcExtraConfig,      PyValueEx "")
+          , (hvLxcTty,              PyValueEx (6 :: Int))
           , (hvLxcStartupWait,      PyValueEx (30 :: Int))
           ])
   ]
-- 
2.0.4

Reply via email to