Commit ce0eb669 authored by Guido Trotter's avatar Guido Trotter
Browse files

kvm console: use socat raw mode with escape

If this is enabled at configure time, we pass in different parameters to
the socat console, making it a lot more manageable.
Signed-off-by: default avatarGuido Trotter <>
Reviewed-by: default avatarIustin Pop <>
parent 37fc2cf5
...@@ -165,6 +165,8 @@ XEN_INITRD = _autoconf.XEN_INITRD ...@@ -165,6 +165,8 @@ XEN_INITRD = _autoconf.XEN_INITRD
KVM_PATH = _autoconf.KVM_PATH KVM_PATH = _autoconf.KVM_PATH
VALUE_DEFAULT = "default" VALUE_DEFAULT = "default"
...@@ -114,6 +114,18 @@ class KVMHypervisor(hv_base.BaseHypervisor): ...@@ -114,6 +114,18 @@ class KVMHypervisor(hv_base.BaseHypervisor):
""" """
return '%s/%s.serial' % (cls._CTRL_DIR, instance_name) return '%s/%s.serial' % (cls._CTRL_DIR, instance_name)
def _SocatUnixConsoleParams():
"""Returns the correct parameters for socat
If we have a new-enough socat we can use raw mode with an escape character.
if constants.SOCAT_ESCAPE:
return "raw,echo=0,escape=%s" % constants.SOCAT_ESCAPE_CODE
return "echo=0,icanon=0"
@classmethod @classmethod
def _InstanceKVMRuntime(cls, instance_name): def _InstanceKVMRuntime(cls, instance_name):
"""Returns the instance KVM runtime filename """Returns the instance KVM runtime filename
...@@ -678,15 +690,8 @@ class KVMHypervisor(hv_base.BaseHypervisor): ...@@ -678,15 +690,8 @@ class KVMHypervisor(hv_base.BaseHypervisor):
""" """
if hvparams[constants.HV_SERIAL_CONSOLE]: if hvparams[constants.HV_SERIAL_CONSOLE]:
# FIXME: The socat shell is not perfect. In particular the way we start shell_command = ("%s STDIO,%s UNIX-CONNECT:%s" %
# it ctrl+c will close it, rather than being passed to the other end. (constants.SOCAT_PATH, cls._SocatUnixConsoleParams(),
# On the other hand if we pass the option 'raw' (or ignbrk=1) there
# will be no way of exiting socat (except killing it from another shell)
# and ctrl+c doesn't work anyway, printing ^C rather than being
# interpreted by kvm. For now we'll leave it this way, which at least
# allows a minimal interaction and changes on the machine.
shell_command = ("%s STDIO,echo=0,icanon=0 UNIX-CONNECT:%s" %
utils.ShellQuote(cls._InstanceSerial( utils.ShellQuote(cls._InstanceSerial(
else: else:
shell_command = "echo 'No serial shell for instance %s'" % shell_command = "echo 'No serial shell for instance %s'" %
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment