aboutsummaryrefslogtreecommitdiff
path: root/kvmx
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-12-30 16:15:14 -0200
committerSilvio Rhatto <rhatto@riseup.net>2017-12-30 16:15:14 -0200
commit4882bc0e6d31e804e4456656c629806eb59eca0a (patch)
treebbcc7e14c68fb76062265c20c6c371c6ea6460cc /kvmx
parentcf9577525e94ff7972edf2b03979b41abdedb95b (diff)
downloadkvmx-4882bc0e6d31e804e4456656c629806eb59eca0a.tar.gz
kvmx-4882bc0e6d31e804e4456656c629806eb59eca0a.tar.bz2
Serial console support thanks to kvm-manager
Diffstat (limited to 'kvmx')
-rwxr-xr-xkvmx28
1 files changed, 28 insertions, 0 deletions
diff --git a/kvmx b/kvmx
index f896815..81b62e5 100755
--- a/kvmx
+++ b/kvmx
@@ -167,6 +167,7 @@ function __kvmx_initialize {
XPRALOG="$LOG_DIR/xpra"
XDMCPLOG="$LOG_DIR/xdmcp"
MONITORFILE="$STATE_DIR/monitor"
+ CONSOLEFILE="$STATE_DIR/console"
if [ -e "$STORAGE/ssh/$VM.key" ]; then
mkdir -p "$STORAGE/ssh"
@@ -378,6 +379,7 @@ function kvmx_up {
-device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 \
-chardev spicevmc,id=spicechannel0,name=vdagent \
-chardev "socket,id=monitor,path=$MONITORFILE,server,nowait" -mon chardev=monitor,mode=readline \
+ -chardev "socket,id=serial0,path=$CONSOLEFILE,server" -device isa-serial,chardev=serial0 \
-smp $smp -soundhw ac97 -cpu host -balloon virtio \
-net nic,model=$nic_model \
-net user,hostfwd=tcp:127.0.0.1:$SSH-:22,hostfwd=udp:127.0.0.1:$XDMCP_PORT-:177$hostfwd $qemu_opts &> $LOGFILE < /dev/null &
@@ -391,6 +393,16 @@ function kvmx_up {
echo $GUEST_DISPLAY > $DISPLAYFILE
echo $XDMCP_PORT > $XDMCPPORTFILE
+ # Thanks kvm-manager code for that portion
+ local screen_log_args=-L
+ if dpkg --compare-versions "$screen_version" ge 4.05; then
+ screen_log_args="-L ./servicelog"
+ fi
+
+ /usr/bin/screen -D -m $screen_log_args \
+ -c $DIRNAME/share/screen/screenrc \
+ -S "kvmx-$VM" -t "kvmx-$VM" socat STDIO,raw,echo=0 "UNIX:${CONSOLEFILE},retry=30" &
+
if [ "$run_spice_client" == "1" ]; then
sleep 1
kvmx_spice
@@ -1373,6 +1385,7 @@ function kvmx_mv {
}
# Interface to QEMU monitor
+# Thanks kvm-manager for the idea
function kvmx_monitor {
if ! kvmx_running; then
echo "$BASENAME: guest $VM is not running"
@@ -1416,6 +1429,21 @@ function kvmx_install {
kvm -m $memory -net nic,model=virtio -net user -drive file=$image -cdrom $media
}
+# Serial console
+function kvmx_console {
+ if ! kvmx_running; then
+ echo "$BASENAME: guest $VM is not running"
+ exit 1
+ fi
+
+ screen -x kvmx-$VM
+}
+
+# Alias to console
+function kvmx_serial {
+ kvmx_serial $*
+}
+
# Dispatch
if type kvmx_$ACTION 2> /dev/null | grep -q "kvmx_$ACTION ()"; then
__kvmx_initialize