From 3c0410a7dc71f30cfc814459ba62297a259c180d Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 10 Mar 2017 13:35:41 -0300 Subject: Display spice log file; kvmx_spice: fixes PORT param and check if machine is running --- kvmx | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/kvmx b/kvmx index 7efb47c..1605bd3 100755 --- 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 -- cgit v1.2.3