as promised, here's my patch against your first version.

-- 
Javier
--- usr/local/sbin/kvmctl	2008-05-31 18:03:14.000000000 -0500
+++ /usr/local/sbin/kvmctl	2008-06-03 12:05:11.000000000 -0500
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Script for controlling kvm (kernel-based virtual machine)
 # (c) [EMAIL PROTECTED]
 #
@@ -149,7 +149,15 @@
 
 }
 
-
+function addtun
+{
+    ifconfig "$1" > /dev/null 2>&1
+    if [ "$?" = "0" ]; then
+	tunctl -d "$1"
+    fi
+    USERID=$(whoami)
+    sudo tunctl -b -u "$USERID" -t "$1"
+}
 
 function usage
 {
@@ -195,7 +203,11 @@
     fi
 
 
-    HDPARM=" -drive file=$HDA,if=$DISKMODEL,boot=on"
+    if [ "$DISKMODEL" == "ide" ]; then
+	HDPARM=" -hda $HDA"
+    else
+	HDPARM=" -drive file=$HDA,if=$DISKMODEL,boot=on"
+    fi
 }
 
 
@@ -216,7 +228,7 @@
 function getvnc
 {
     VNC=`grep ^"$1 " $globalconf | awk {'print $2'}`
-    if [ -z $VNC ] || [ x$VNC == "x-" ];then
+    if [ -z "$VNC" ] || [ "x$VNC" == "x-" ]; then
 	vf=$rundir/$1.vnc
 	if [ -f $vf ];then
 	    VNC=`cat $rundir/$1.vnc`
@@ -370,8 +382,15 @@
     if ! isrunning $name;then
 	createhdparm $DISKMODEL 
 	shift 2
+	addtun "$IFNAME"
+	if [ "$1" == "sdl" ]; then
+	    shift
+	    SCREEN=""
+	else
+	    SCREEN=" -vnc :$VNC"
+	fi
 
-	nice -n $NICE $IONICEBIN -n $IONICE $TASKSET -c $CPULIST /usr/local/bin/qemu-system-x86_64 -std-vga -cpu $CPU -k $KEYBOARD -localtime -name $name  -usbdevice tablet -smp $SMP -m $MEM -vnc :$VNC $HDPARM  -net nic,macaddr=$MACADDR,model=$NICMODEL  -net tap,ifname=$IFNAME  -daemonize -pidfile $pidfile -monitor unix:$monfile,server,nowait $EXTRAPARM $* > $logfile 2>&1
+	nice -n $NICE $IONICEBIN -n $IONICE $TASKSET -c $CPULIST /usr/local/bin/qemu-system-x86_64 -cpu $CPU -k $KEYBOARD -localtime -name $name  -usbdevice tablet -smp $SMP -m $MEM $SCREEN $HDPARM  -net nic,macaddr=$MACADDR,model=$NICMODEL  -net tap,ifname=$IFNAME  -daemonize -pidfile $pidfile -monitor unix:$monfile,server,nowait $EXTRAPARM $* > $logfile 2>&1
 	if [ $? -eq 0 ];then
 	    pid=`cat $pidfile`
 	    #renice $NICE -p $pid > /dev/null 2>&1

Reply via email to