From 714882ba4ce394fd4d317301b8ec13925af6c447 Mon Sep 17 00:00:00 2001 From: micuell Date: Sun, 12 Aug 2018 15:32:25 +0200 Subject: [PATCH] vmstop function generated and ready to test --- nlvmi | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/nlvmi b/nlvmi index 61ae12f..b84d95a 100755 --- a/nlvmi +++ b/nlvmi @@ -140,22 +140,22 @@ function vmstart { USBDEV3=""; fi if [ ${array[23]}!="" ]; then USBDEV3="-usbdevice ${array[22]}"; fi - if [ ${array[29]}=="" ]; then - CPUTYPE=""; fi - if [ ${array[29]}!="" ]; then - CPUTYPE="-cpu ${array[29]}"; fi - if [ ${array[27]}=="" ]; then - SMP=""; fi - if [ ${array[27]}!="" ]; then - SMP="-smp ${array[27]}"; fi - if [ ${array[26]}=="" ]; then - MEMORY=""; fi - if [ ${array[26]}!="" ]; then - MEMORY="-m ${array[26]}"; fi if [ ${array[28]}=="" ]; then - CUSTOM=""; fi + CPUTYPE=""; fi if [ ${array[28]}!="" ]; then - CUSTOM="${array[28]}"; fi + CPUTYPE="-cpu ${array[28]}"; fi + if [ ${array[26]}=="" ]; then + SMP=""; fi + if [ ${array[26]}!="" ]; then + SMP="-smp ${array[26]}"; fi + if [ ${array[25]}=="" ]; then + MEMORY=""; fi + if [ ${array[25]}!="" ]; then + MEMORY="-m ${array[25]}"; fi + if [ ${array[27]}=="" ]; then + CUSTOM=""; fi + if [ ${array[27]}!="" ]; then + CUSTOM="${array[27]}"; fi tunctl -t $TAPDEV1 -u ${array[3]} brctl addif br0 $TAPDEV1 ifconfig $TAPDEV1 up @@ -167,6 +167,20 @@ function vmstart { export VMFOUND="yes" } + +function vmstop { + if [ -e $RUNDIRDIRECTORY/$1.pid ]; then echo "pidfile not exist"; exit 1; fi + if [ $LOGLEVEL -gt "1" ]; then echo "stopvm function entered for VM $1"; fi + sqlite3 $SQLITEFILE "SELECT * FROM vms WHERE vmname=$1" | while read line; do + IFS='|' read -r -a array <<< "$line" + echo "system_powerdown" | socat - unix-connect:$RUNDIRDIRECTORY/${array[1]}.mon >/dev/null + STOPPED="no" + while [ $STOPPED = "no" ]; do + ps -ef | grep `cat $RUNDIRDIRECTORY/${array[1]}.pid` | grep -v grep >/dev/null || STOPPED="yes" + done + done +} + #mainloop if [ $# -gt 0 ]; then if [ $1 == "createdb" ]; then