+++ /dev/null
-#!/bin/bash -xe
-
-#
-# Create tun and bridge interfaces for qemu.
-#
-
-TAP=tap0
-BR=br0
-
-die() {
- echo $@
- exit 1
-}
-
-up() {
- /sbin/tunctl -b -t $TAP
- /sbin/ifconfig $TAP up
- /sbin/brctl addbr $BR
- /sbin/brctl addif $BR $TAP
- /sbin/ifconfig $BR 192.168.123.1 netmask 255.255.255.0
- /sbin/ifconfig $BR up
-}
-
-down() {
- /sbin/ifconfig $BR down
- /sbin/ifconfig $TAP down
- /sbin/brctl delbr $BR
- /sbin/tunctl -d $TAP
-}
-
-ARG="x$1"
-if [ $ARG == "xup" ]; then
- up
-elif [ $ARG == "xdown" ]; then
- down
-else
- die "must specify either up or down."
-fi
--- /dev/null
+die() {
+ echo $@
+ exit 1
+}
+
+run_vm() {
+ ID=$1
+ shift
+ NARGS=$@
+ ADMIN_PORT=`expr 2232 + $ID`
+ MID_BYTE=`printf "%02X" $ID`
+ MAC_ADDR="F0:DE:$MID_BYTE:58:B2:69"
+ /sbin/modprobe kvm kvm_intel kvm_amd || die "modprobe failed"
+ echo "running qemu with ssh port $ADMIN_PORT, vnc ID $ID"
+ VNC_EFFECTIVE_PORT=`expr 5900 + $ID`
+ echo "see output with vncviewer 127.0.0.1:$VNC_EFFECTIVE_PORT"
+ qemu-kvm \
+ -daemonize \
+ -vga std \
+ -redir tcp:$ADMIN_PORT::22 \
+ -vnc 127.0.0.1:$ID \
+ -net nic,vlan=0,model=e1000 \
+ -net user,vlan=0,net=10.0.2.0/8,host=10.0.2.2,hostname=vm$ID \
+ -net nic,vlan=1,macaddr=$MAC_ADDR,model=e1000 \
+ -net socket,vlan=1,mcast=230.0.0.1:1234 \
+ $NARGS || die "qemu invocation failed."
+}
+
+# Tap stuff (currently unused):
+#-net nic,vlan=0,macaddr=$MAC_ADDR,model=e1000 \
+#-net tap,vlan=0,ifname=tap0,downscript=no,script=no \
+
+# To add to /etc/hosts in VMs:
+# 192.168.123.10 vm0.local vm0
+# 192.168.123.11 vm1.local vm1
+# 192.168.123.12 vm2.local vm2
+# 192.168.123.13 vm3.local vm3
+# 192.168.123.14 vm4.local vm4
+# 192.168.123.15 vm5.local vm5
+# 192.168.123.16 vm6.local vm6