--- /dev/null
+Svenne's KVM control scripts
+(c) 2011- Svenne Krap
+
+Released under the 2-clause BSD license
--- /dev/null
+#!/bin/bash
+cd /virtual-machines
+for x in *.vm ; do ./stop.sh $x ; done
--- /dev/null
+Dir for pid-files
--- /dev/null
+#!/bin/bash
+
+IP=0.0.0.0
+MONPORT=$(( 8500+${VMID} ))
+VNCPORT=$(( ${VMID} ))
+SERPORT=$(( 9900+${VMID} ))
+TAP_NAME="kvm${VMID}"
+PWD=$( pwd )
+
+if [ -n "$DRIVE2" ] ; then
+ DRIVE2="-drive file=${DRIVE2},if=virtio,cache=none"
+fi
+
+if [ -n "$CORES" ] ; then
+ CORES="-smp cores=$CORES"
+
+fi
+if [ -n "$TABLET" ] ; then
+ TABLET="-usbdevice tablet"
+fi
+
+if [ -z "$VLAN" ] ; then
+ VLAN=0
+fi
+if [ ! -L _run/ifup_br${VLAN} ] ; then
+ pushd _run
+ ln -s ifup_common ifup_br${VLAN}
+ popd
+fi
+
+if [ -z "MACADDR" ] ; then
+ VLANDIGIT=$( echo 'ibase=10;obase=16;'$VLAN | bc)
+ VMDIGIT=$( echo 'ibase=10;obase=16;'$VMID | bc )
+ MACADDR="C0:FF:EE:19:$VLANDIGIT:$VMDIGIT"
+fi
--- /dev/null
+ifup_common
\ No newline at end of file
--- /dev/null
+#!/bin/sh
+switch=${0:10}
+/bin/ifconfig $1 0.0.0.0 up
+/sbin/brctl addif ${switch} $1
--- /dev/null
+#!/bin/bash
+. _run/common.sh
+
+echo "$0 $NAME started, vnc at $VNCPORT, monitor at $MONPORT"
+qemu-kvm \
+ -name $NAME \
+ -monitor telnet:${IP}:${MONPORT},server,nowait \
+ -drive file=${BOOTDRIVE},if=ide,cache=none \
+ -boot order=c \
+ $CORES \
+ $DRIVE2 \
+ $TABLET \
+ -m ${MEMORY} \
+ -k da \
+ -vga std \
+ -vnc :${VNCPORT} \
+ -enable-kvm \
+ -rtc base=utc \
+ -daemonize \
+ -cpu kvm64 \
+ -net nic,macaddr=${MACADDR} \
+ -net tap,ifname=${TAP_NAME},script=_run/ifup_br${VLAN} \
+ -pidfile _pids/$NAME \
+ $*
--- /dev/null
+#!/bin/bash
+. _run/common.sh
+
+echo "$0 $NAME started, vnc at $VNCPORT, monitor at $MONPORT"
+qemu-kvm \
+ -name $NAME \
+ -monitor telnet:${IP}:${MONPORT},server,nowait \
+ -drive file=${BOOTDRIVE},if=virtio,cache=none \
+ -boot order=c \
+ $CORES \
+ $DRIVE2 \
+ $TABLET \
+ -m ${MEMORY} \
+ -k da \
+ -vga std \
+ -vnc :${VNCPORT} \
+ -enable-kvm \
+ -rtc base=utc \
+ -daemonize \
+ -cpu kvm64 \
+ -net nic,model=virtio,macaddr=${MACADDR} \
+ -net tap,ifname=${TAP_NAME},script=_run/ifup_br${VLAN} \
+ -pidfile _pids/$NAME \
+ $*
--- /dev/null
+#!/bin/bash
+if [ $# -lt 1 ] ; then
+ echo "$0 <machine-conf>"
+ exit
+fi
+if [ ! -f $1 ] ; then
+ echo "<machine conf> does not exists at $1";
+ exit
+fi
+. $1
+if [ ${AUTOSTART} -ne 1 ] ; then
+ echo "$1 not autostarting"
+ exit
+else
+ echo "$1 autostart"
+fi
+shift
+. _run/${TYPE}.sh
--- /dev/null
+#!/bin/bash
+TYPE=virtio
+VMID=3
+NAME="gluster"
+BOOTDRIVE="gluster://otherhost/gv0/qcows/docker.qcow2"
+MEMORY=2048
+CORES=2
+VLAN=3
+AUTOSTART=1
--- /dev/null
+#!/bin/bash
+if [ $# -lt 1 ] ; then
+ echo "$0 <machine-conf>"
+ exit
+fi
+if [ ! -f $1 ] ; then
+ echo "<machine conf> does not exists at $1";
+ exit
+fi
+. $1
+if [ ! -f _pids/$NAME ] ; then
+ echo "machine $NAME is not running";
+ exit
+fi
+. _run/common.sh
+kill $( cat _pids/$NAME )
+rm _pids/$NAME
--- /dev/null
+#!/bin/bash
+#ps aux | grep [q]emu | grep -P -o "\-name ([^ ]*) .* -vnc ([^ ]*) " | cut -b 7-
+ps aux | gawk '/qemu/ {match($0,"-name ([^ ]*).*-vnc ([^ ]*)", a) ; print(a[1], "pid " $2, a[2])} ' | grep -v "(\[^"
--- /dev/null
+#!/bin/bash
+echo -n C0:FF:EE ; for i in `seq 1 3` ; do echo -n `echo ":$RANDOM$RANDOM" | cut -n -c -3` ;done; echo
--- /dev/null
+#!/bin/bash
+TYPE=plain
+VMID=2
+NAME="plain"
+BOOTDRIVE="qcows/plain.qcow2"
+MEMORY=2048
+CORES=2
+VLAN=3
+AUTOSTART=1
--- /dev/null
+#!/bin/bash
+if [ $# -lt 1 ] ; then
+ echo "$0 <machine-conf>"
+ exit
+fi
+if [ ! -f $1 ] ; then
+ echo "<machine conf> does not exists at $1";
+ exit
+fi
+. $1
+shift
+. _run/${TYPE}.sh
--- /dev/null
+#!/bin/bash
+if [ $# -lt 1 ] ; then
+ echo "$0 <machine-conf>"
+ exit
+fi
+if [ ! -f $1 ] ; then
+ echo "<machine conf> does not exists at $1";
+ exit
+fi
+. $1
+if [ ! -f _pids/$NAME ] ; then
+ echo "machine $NAME is not running";
+ exit
+fi
+echo "system_powerdown" | socat - TCP:localhost:$MONPORT
+rm _pids/$NAME
--- /dev/null
+#!/bin/bash
+grep MEM *.vm | awk 'FS="=" { sum += $2 } END { print sum } '
--- /dev/null
+#!/bin/bash
+TYPE=virtio
+VMID=1
+NAME="virtio"
+BOOTDRIVE="/dev/vg0/kvm__virtio"
+MEMORY=2048
+CORES=2
+VLAN=3
+AUTOSTART=1