]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Display spice log file; kvmx_spice: fixes PORT param and check if machine is running
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 10 Mar 2017 16:35:41 +0000 (13:35 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 10 Mar 2017 16:35:41 +0000 (13:35 -0300)
kvmx

diff --git a/kvmx b/kvmx
index 7efb47cbfb763b4340d714f514d8d9bcc6129d78..1605bd38f24a84204eaf0604439f713ddc666ed5 100755 (executable)
--- a/kvmx
+++ b/kvmx
@@ -30,6 +30,20 @@ KVMX_BASE="$DIRNAME"
 
 # Run spice client
 function kvmx_spice {
+  if ! kvmx_running; then
+    echo "$BASENAME: guest $VM is not running"
+    exit 1
+  fi
+
+  # Ensure we have the right port configuration: we can also be
+  # running directly from command line.
+  PORT="`cat $PORTFILE`"
+
+  if [ -z "$PORT" ]; then
+    echo "$BASENAME: cannot get spice port for $VM."
+    exit 1
+  fi
+
   # https://lists.freedesktop.org/archives/spice-devel/2013-September/014643.html
   SPICE_NOGRAB=1 spicec --host localhost --port $PORT &> $SPICEFILE &
   #spicy -h localhost -p $PORT
@@ -424,9 +438,24 @@ function kvmx_status {
 
 # Print guest log
 function kvmx_log {
-  if [ -e "$LOGFILE" ]; then
+  local blank_line=""
+
+  if [ -s "$LOGFILE" ]; then
+    blank_line="1"
+    echo "In $LOGFILE:"
+    echo ""
     cat $LOGFILE
   fi
+
+  if [ -s "$SPICEFILE" ]; then
+    if [ ! -z "$blank_line" ]; then
+      echo ""
+    fi
+
+    echo "In $SPICEFILE:"
+    echo ""
+    cat $SPICEFILE
+  fi
 }
 
 # Dispatch