diff --git a/nlvmi b/nlvmi index 83da111..fa6c345 100755 --- a/nlvmi +++ b/nlvmi @@ -110,16 +110,24 @@ function vmstart { if [ $LOGLEVEL -gt "1" ]; then echo "startvm function entered for vmid $1"; fi sqlite3 $SQLITEFILE "SELECT * FROM vms WHERE id=$1" | while read line; do IFS='|' read -r -a array <<< "$line" + if ! `id -u ${array[2]} &>/dev/null`; then + useradd ${array[2]} -d /run/nlvmi -g nlvmi -M -s /bin/false -G kvm; + if [ $LOGLEVEL -gt "1" ]; then echo "user ${array[2]} created"; fi + fi + if [ -e $RUNDIRECTORY/${array[1]}.* ]; then + if [ $LOGLEVEL -gt "1" ]; then echo "chowning pid and monfiles "; fi + chown ${array[2]}:nlvmi $RUNDIRECTORY/${array[1]}.* + fi if [ ! -z ${array[5]} ]; then CPUTYPE="-cpu ${array[5]}"; fi if [ ! -z ${array[6]} ]; then SMP="-smp ${array[6]}"; fi if [ ! -z ${array[7]} ]; then MEMORY="-m ${array[7]}"; fi if [ ! -z ${array[8]} ]; then USBDEV="-usb -device usb-ehci,id=ehci -device usb-${array[8]},bus=usb-bus.0"; fi if [ ! -z ${array[10]} ]; then CUSTOM="${array[10]}"; fi - if [ ! -z ${array[13]} ]; then DRIVE1="-drive file=${array[13]}"; fi + if [ ! -z ${array[13]} ]; then DRIVE1="-drive file=${array[13]}"; chown ${array[2]}:nlvmi ${array[13]}; fi if [ ! -z ${array[14]} ]; then FORMAT1=",format=${array[14]},if=virtio"; fi - if [ ! -z ${array[15]} ]; then DRIVE2="-drive file=${array[15]},format=raw,if=virtio,aio=native"; fi + if [ ! -z ${array[15]} ]; then DRIVE2="-drive file=${array[15]}"; chown ${array[2]}:nlvmi ${array[15]}; fi if [ ! -z ${array[16]} ]; then FORMAT2=",format=${array[16]},if=virtio"; fi - if [ ! -z ${array[17]} ]; then DRIVE3="-drive file=${array[17]},format=raw,if=virtio,aio=native"; fi + if [ ! -z ${array[17]} ]; then DRIVE3="-drive file=${array[17]}"; chown ${array[2]}:nlvmi ${array[17]}; fi if [ ! -z ${array[18]} ]; then FORMAT3=",format=${array[18]},if=virtio"; fi if [ ! -z ${array[19]} ]; then CDROM="-cdrom ${array[19]}"; fi if [ ! -z ${array[20]} ]; then TAPDEV1="-netdev tap,ifname=${array[20]},script=no,id=net0"; tunctl -t ${array[20]} -u ${array[2]} && ifconfig ${array[20]} up; fi @@ -133,7 +141,7 @@ function vmstart { if [ ! -z ${array[28]} ]; then BRDEV3="${array[28]}"; brctl addif ${array[28]} ${array[26]}; fi if [ ! -z ${array[30]} ]; then WEBSOCK=",websocket=${array[30]}"; else WEBSOCK=""; fi if [ ! -z ${array[29]} ]; then VNCPORT="-vnc :${array[29]}$WEBSOCK,password"; fi - COMMAND=(su ${array[2]} -c "${array[4]} -enable-kvm $CPUTYPE $MEMORY $SMP -boot ${array[11]} $USBDEV -k ${array[9]} -daemonize $DRIVE1$FORMAT1 $DRIVE2$FORMAT2 $DRIVE3$FORMAT3 $CDROM $MACADDR1 $TAPDEV1 $MACADDR2 $TAPDEV2 $MACADDR3 $TAPDEV3 $VNCPORT $CUSTOM -pidfile $RUNDIRECTORY/${array[1]}.pid -monitor unix:$RUNDIRECTORY/${array[1]}.mon,server,nowait") + COMMAND=(su - ${array[2]} -s /bin/bash -c "${array[4]} -enable-kvm $CPUTYPE $MEMORY $SMP -boot ${array[11]} $USBDEV -k ${array[9]} -daemonize $DRIVE1$FORMAT1 $DRIVE2$FORMAT2 $DRIVE3$FORMAT3 $CDROM $MACADDR1 $TAPDEV1 $MACADDR2 $TAPDEV2 $MACADDR3 $TAPDEV3 $VNCPORT $CUSTOM -pidfile $RUNDIRECTORY/${array[1]}.pid -monitor unix:$RUNDIRECTORY/${array[1]}.mon,server,nowait") if [ $LOGLEVEL -gt "1" ]; then echo ${COMMAND[@]}; fi `"${COMMAND[@]}"` #Set VNC Password @@ -153,7 +161,7 @@ function vmstop { STOPPED="no" COUNTER=0 while [ $STOPPED = "no" ]; do - if [ $COUNTER==100 ]; then + if [ $COUNTER == 200 ]; then kill `cat $RUNDIRECTORY/${array[1]}.pid` echo "${array[1]} forcefully killed!"; STOPPED="yes" diff --git a/web/index.php b/web/index.php index d45ca54..c102635 100644 --- a/web/index.php +++ b/web/index.php @@ -396,13 +396,13 @@ if (isset($_SESSION['username'])){ echo ""; // echo "$arrColnames[$col]
"; } elseif (preg_match('/format/', $arrColnames[$col])){ - echo "
$arrColnames[$col]
"; + echo "raw"; + echo "qcow2"; + echo "
"; } elseif ($arrColnames[$col] == "autostart"){ $checked=""; if ($val=="1"){