root / tools / kvm-console-wrapper @ ae082df0
History | View | Annotate | Download (1.5 kB)
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 |
INSTANCE="$1" |
21 |
SOCAT="$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 |
"$SOCAT" "$PARAMS" "$CONSOLE" |