Revision 2f4c951e

b/Makefile.am
490 490

  
491 491
dist_tools_SCRIPTS = \
492 492
	$(dist_tools_PYTHON) \
493
	tools/kvm-console-wrapper \
493 494
	tools/xm-console-wrapper
494 495

  
495 496
pkglib_python_scripts = \
b/lib/constants.py
144 144
DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util"
145 145
SETUP_SSH = _autoconf.TOOLSDIR + "/setup-ssh"
146 146
KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup"
147
KVM_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/kvm-console-wrapper"
147 148
XM_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/xm-console-wrapper"
148 149
ETC_HOSTS = "/etc/hosts"
149 150
DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
b/lib/hypervisor/hv_kvm.py
1146 1146

  
1147 1147
    """
1148 1148
    if hvparams[constants.HV_SERIAL_CONSOLE]:
1149
      cmd = [constants.SOCAT_PATH,
1149
      cmd = [constants.KVM_CONSOLE_WRAPPER,
1150
             constants.SOCAT_PATH, utils.ShellQuote(instance.name),
1151
             utils.ShellQuote(cls._InstanceMonitor(instance.name)),
1150 1152
             "STDIO,%s" % cls._SocatUnixConsoleParams(),
1151 1153
             "UNIX-CONNECT:%s" % cls._InstanceSerial(instance.name)]
1152 1154
      return objects.InstanceConsole(instance=instance.name,
b/test/ganeti.hypervisor.hv_kvm_unittest.py
49 49
    cons = self._Test(instance, hvparams)
50 50
    self.assertEqual(cons.kind, constants.CONS_SSH)
51 51
    self.assertEqual(cons.host, instance.primary_node)
52
    self.assertEqual(cons.command[0], constants.SOCAT_PATH)
52
    self.assertEqual(cons.command[0], constants.KVM_CONSOLE_WRAPPER)
53
    self.assertEqual(cons.command[1], constants.SOCAT_PATH)
53 54

  
54 55
  def testVnc(self):
55 56
    instance = objects.Instance(name="kvm.example.com",
b/tools/kvm-console-wrapper
1
#!/bin/bash
2

  
3
# Copyright (C) 2011 Google Inc.
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19

  
20
SOCAT="$1"
21
INSTANCE="$2"
22
MONITOR="$3"
23
PARAMS="$4"
24
CONSOLE="$5"
25

  
26
unpause() {
27
  echo "info status" |
28
    "$SOCAT" STDIO "UNIX-CONNECT:$MONITOR" 2>/dev/null |
29
    grep -q '^VM status: paused' || return
30
  # As there is no way to be sure when the main socat has actually connected to
31
  # the instance console, sleep for a few seconds before unpausing the
32
  # instance. This is a tradeoff between missing some console output if the
33
  # node is overloaded and making the user wait everytime when the node isn't
34
  # so busy.
35
  sleep 3
36
  # Send \r\n after notice as terminal is in raw mode
37
  printf "Instance $INSTANCE is paused, unpausing\r\n"
38
  echo "c" | "$SOCAT" STDIO "UNIX-CONNECT:$MONITOR" &>/dev/null
39
}
40

  
41
unpause &
42
exec "$SOCAT" "$PARAMS" "$CONSOLE"

Also available in: Unified diff