diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-03-10 13:21:27 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-03-10 13:21:27 -0300 |
commit | a2b527b6a0fe331e4a6bd2dcac019873babd1e9f (patch) | |
tree | 1d2519479fb13eefca94d2f6a9706874aa043c48 | |
parent | de2c9e659f05c2ab9c83d0a9972124b4b389505d (diff) | |
download | kvmx-a2b527b6a0fe331e4a6bd2dcac019873babd1e9f.tar.gz kvmx-a2b527b6a0fe331e4a6bd2dcac019873babd1e9f.tar.bz2 |
Check guest PID, use a logfile for spice and nohup for kvm invocation
-rwxr-xr-x | kvmx | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -31,7 +31,7 @@ KVMX_BASE="$DIRNAME" # Run spice client function kvmx_spice { # https://lists.freedesktop.org/archives/spice-devel/2013-September/014643.html - SPICE_NOGRAB=1 spicec --host localhost --port $PORT & + SPICE_NOGRAB=1 spicec --host localhost --port $PORT &> $SPICEFILE & #spicy -h localhost -p $PORT #remote-viewer spice://localhost:$PORT @@ -79,14 +79,15 @@ function kvmx_up { fi # Run virtual machine - kvm -m 2048 -name $VM -drive file=$image,if=virtio -vga qxl $shared \ + # See https://en.wikipedia.org/wiki/Nohup#Overcoming_hanging + nohup kvm -m 2048 -name $VM -drive file=$image,if=virtio -vga qxl $shared \ -spice port=$PORT,addr=127.0.0.1,disable-ticketing,streaming-video=off,jpeg-wan-compression=never,playback-compression=off,zlib-glz-wan-compression=never,image-compression=off \ -device virtio-serial-pci \ -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 \ -chardev spicevmc,id=spicechannel0,name=vdagent \ -smp 2 -soundhw ac97 -cpu host -balloon virtio \ -net nic,model=virtio \ - -net user,hostfwd=tcp:127.0.0.1:$SSH-:22$hostfwd &> $LOGFILE & + -net user,hostfwd=tcp:127.0.0.1:$SSH-:22$hostfwd &> $LOGFILE < /dev/null & PID="$!" @@ -142,6 +143,11 @@ function kvmx_running { fi PID="`cat $PIDFILE`" + + if [ -z "$PID" ]; then + return 1 + fi + ps $PID &> /dev/null return $? @@ -253,6 +259,7 @@ function kvmx_initialize { PORTFILE="$STATE_DIR/port" SSHFILE="$STATE_DIR/ssh" LOGFILE="$STATE_DIR/log" + SPICEFILE="$STATE_DIR/spice" mkdir -p $STATE_DIR if [ ! -e "$image" ] && [ "$ACTION" != "up" ] && [ "$ACTION" != "purge" ] && [ "$ACTION" != "destroy" ]; then |