]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Implements log dir and spice pid file
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 31 Mar 2017 10:22:25 +0000 (07:22 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 31 Mar 2017 10:22:25 +0000 (07:22 -0300)
kvmx

diff --git a/kvmx b/kvmx
index d70666998deba7e57fa2ac95597d59a4f9ee9531..7a5b3ed411a4a18f9f172b9adb980f697313bce1 100755 (executable)
--- a/kvmx
+++ b/kvmx
@@ -125,11 +125,13 @@ function __kvmx_initialize {
     KVMX_PROJECT_FOLDER="`dirname $KVMXFILE`"
     STORAGE="`dirname $image`"
     STATE_DIR="$STORAGE/state/$VM"
+    LOG_DIR="$STORAGE/log"
     PIDFILE="$STATE_DIR/pid"
     PORTFILE="$STATE_DIR/port"
     SSHFILE="$STATE_DIR/ssh"
-    LOGFILE="$STATE_DIR/log"
     SPICEFILE="$STATE_DIR/spice"
+    LOGFILE="$LOG_DIR/qemu"
+    SPICELOG="$LOG_DIR/spice"
 
     if [ -e "$STORAGE/ssh/$VM.key" ]; then
       mkdir -p "$STORAGE/ssh"
@@ -146,7 +148,7 @@ function __kvmx_initialize {
 
     __kvmx_ssh_command $SSHKEY
 
-    mkdir -p $STATE_DIR
+    mkdir -p $STATE_DIR $LOG_DIR
 
     if [ ! -e "$image" ] && [ "$ACTION" != "up" ] && [ "$ACTION" != "purge" ] && [ "$ACTION" != "destroy" ]; then
       echo "$BASENAME: file not found: $image"
@@ -172,10 +174,13 @@ function kvmx_spice {
   fi
 
   # https://lists.freedesktop.org/archives/spice-devel/2013-September/014643.html
-  SPICE_NOGRAB=1 spicec --host localhost --port $PORT &> $SPICEFILE &
+  SPICE_NOGRAB=1 spicec --host localhost --port $PORT &> $SPICELOG &
   #spicy -h localhost -p $PORT
   #remote-viewer spice://localhost:$PORT
 
+  SPICEPID="$!"
+  echo "$SPICEPID" > $SPICEFILE
+
   # Give time to connect
   sleep 5
 
@@ -703,8 +708,8 @@ function kvmx_log {
     logs="$logs $LOGFILE"
   fi
 
-  if [ -s "$SPICEFILE" ]; then
-    logs="$logs $SPICEFILE"
+  if [ -s "$SPICELOG" ]; then
+    logs="$logs $SPICELOG"
   fi
 
   tail -F $logs