Revision ce0eb669

b/lib/constants.py
165 165

  
166 166
KVM_PATH = _autoconf.KVM_PATH
167 167
SOCAT_PATH = _autoconf.SOCAT_PATH
168
SOCAT_ESCAPE = _autoconf.SOCAT_ESCAPE
169
SOCAT_ESCAPE_CODE = "0x1d"
168 170
KVM_MIGRATION_PORT = _autoconf.KVM_MIGRATION_PORT
169 171

  
170 172
VALUE_DEFAULT = "default"
b/lib/hypervisor/hv_kvm.py
114 114
    """
115 115
    return '%s/%s.serial' % (cls._CTRL_DIR, instance_name)
116 116

  
117
  @staticmethod
118
  def _SocatUnixConsoleParams():
119
    """Returns the correct parameters for socat
120

  
121
    If we have a new-enough socat we can use raw mode with an escape character.
122

  
123
    """
124
    if constants.SOCAT_ESCAPE:
125
      return "raw,echo=0,escape=%s" % constants.SOCAT_ESCAPE_CODE
126
    else:
127
      return "echo=0,icanon=0"
128

  
117 129
  @classmethod
118 130
  def _InstanceKVMRuntime(cls, instance_name):
119 131
    """Returns the instance KVM runtime filename
......
678 690

  
679 691
    """
680 692
    if hvparams[constants.HV_SERIAL_CONSOLE]:
681
      # FIXME: The socat shell is not perfect. In particular the way we start
682
      # it ctrl+c will close it, rather than being passed to the other end.
683
      # On the other hand if we pass the option 'raw' (or ignbrk=1) there
684
      # will be no way of exiting socat (except killing it from another shell)
685
      # and ctrl+c doesn't work anyway, printing ^C rather than being
686
      # interpreted by kvm. For now we'll leave it this way, which at least
687
      # allows a minimal interaction and changes on the machine.
688
      shell_command = ("%s STDIO,echo=0,icanon=0 UNIX-CONNECT:%s" %
689
                       (constants.SOCAT_PATH,
693
      shell_command = ("%s STDIO,%s UNIX-CONNECT:%s" %
694
                       (constants.SOCAT_PATH, cls._SocatUnixConsoleParams(),
690 695
                        utils.ShellQuote(cls._InstanceSerial(instance.name))))
691 696
    else:
692 697
      shell_command = "echo 'No serial shell for instance %s'" % instance.name

Also available in: Unified diff