--- /dev/null
+kvm-manager (0.1~pre0) UNRELEASED; urgency=low
+
+ * removed TAP and MAC from kvm-creator -- they are automatically
+ generated from the guest name. kvm-manager still respects the
+ environment variables, if they are set; but admins should avoid
+ setting them from now on.
+
+ -- Daniel Kahn Gillmor <dkg@fifthhorseman.net> Mon, 06 Jun 2011 14:45:38 -0400
+
Authors: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Jamie McClelland <jm@mayfirst.org>
-Copyright © 2009
+ Greg Lyle <greg@stealthisemail.com>
+Copyright © 2009-2011
License: GPL-3+
This is a small set of scripts to make it relatively easy to manage a
Dependencies:
runit : for system supervision
- uml-utilities : for tunctl for the tun/tap interface
kvm : for the virtual machine emulator
socat : For communications with the monitor and console of guests
screen : for the detached, logged serial console
* Install dependencies:
- apt-get install runit uml-utilities kvm screen bridge-utils lvm2 udev socat
+ apt-get install runit kvm screen bridge-utils lvm2 udev socat
If you want to be able to use di-maker, you'll also need:
To create a KVM instance, run:
- kvm-creator create $GUESTNAME [ $VG [$DISKSIZE [$RAM [$TAP [$MAC] ] ] ] ]
+ kvm-creator create $GUESTNAME [ $VG [$DISKSIZE [$RAM] ] ]
You can replace "create" with "demo" to see the default values for non-
specified options.
[ "$CMD" == "create" ] && mkdir -p /etc/sv/kvm
-ls /etc/sv/kvm/* &> /dev/null
-if [ "$?" -eq 0 ]; then
- TAP="${5:-${1}0}"
- MAC="${6:-$(printf "%s:%02x" "$(cat /etc/sv/kvm/*/env/MAC | sort | head -n1 | cut -f 1-5 -d: )" "$(( 0x$( cat /etc/sv/kvm/*/env/MAC | cut -f 6 -d: | sort | tail -n 1 ) + 1 ))" )}"
-else
- TAP=tap0
- # use a locally-administered MAC address:
- MAC=${6:-02:00:00:00:00:01}
-fi
-
usage() {
- die "USAGE: kvm-creator create|destroy|demo guestname [volumegroup [disksize [ram [tap [mac] ] ] ] ]"
+ die "USAGE: kvm-creator create|destroy|demo guestname [volumegroup [disksize [ram] ] ]"
}
chmod a+x "/etc/sv/kvm/$NAME/"{run,finish,log/run}
echo "$NAME" > "/etc/sv/kvm/$NAME/env/OWNER"
echo "$NAME" > "/etc/sv/kvm/$NAME/env/VMNAME"
- echo "$TAP" > "/etc/sv/kvm/$NAME/env/TAP"
echo "$RAM" > "/etc/sv/kvm/$NAME/env/RAM"
- echo "$MAC" > "/etc/sv/kvm/$NAME/env/MAC"
echo "$DISK" > "/etc/sv/kvm/$NAME/env/HDA"
}
demo() {
validate
- for foo in NAME VG SIZE RAM TAP MAC DISK ; do
+ for foo in NAME VG SIZE RAM DISK ; do
echo "$foo : ${!foo}"
done
## expect to pull these values from the environment:
# VMNAME=snapper
# OWNER=jrollins
-# TAP=tap0
# RAM=512
-# MAC=52:54:00:12:34:56
# HDA=/path/to/disk0 # optional
# HDB=/path/to/disk1 # optional
# HDC=/path/to/disk2 # optional
exit 1
fi
+TAP="${TAP:-${NAME}}"
+# MAC address is derived from a hash of the host's name and the guest's name:
+MAC="${MAC:-$(printf "02:%s" "$(printf "%s\0%s" "$(hostname)" "${VMNAME}" | sha256sum | sed 's/\(..\)/\1:/g' | cut -f1-5 -d:)" )}"
+
###################
OWNERGROUP=$(groups "$OWNER" | cut -f1 -d\ )
OWNERHOME=$(getent passwd "$OWNER" | cut -f6 -d: )