aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2011-06-06 19:07:01 -0400
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>2011-06-06 19:07:01 -0400
commit5b86edadc37019b175509d348ed009de4b8f756f (patch)
tree64cfe426622542960271fdb1258842a2da41368b
parentd2a81ec6c28128ee4a745e01f8075add549152ba (diff)
downloadkvm-manager-5b86edadc37019b175509d348ed009de4b8f756f.tar.gz
kvm-manager-5b86edadc37019b175509d348ed009de4b8f756f.tar.bz2
removed TAP and MAC arguments from kvm-creator, and updated README to reflect the change
-rw-r--r--Changelog9
-rw-r--r--README8
-rwxr-xr-xkvm-creator16
-rwxr-xr-xkvm-manager6
4 files changed, 19 insertions, 20 deletions
diff --git a/Changelog b/Changelog
new file mode 100644
index 0000000..cf46351
--- /dev/null
+++ b/Changelog
@@ -0,0 +1,9 @@
+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
+
diff --git a/README b/README
index 923df4b..2f9b012 100644
--- a/README
+++ b/README
@@ -2,7 +2,8 @@ KVM-Manager
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
@@ -16,7 +17,6 @@ instance's console.
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
@@ -34,7 +34,7 @@ INSTALLATION
* 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:
@@ -75,7 +75,7 @@ INSTALLING DEBIAN ONTO YOUR VIRTUAL SERVER
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.
diff --git a/kvm-creator b/kvm-creator
index 541d32c..8d2afa7 100755
--- a/kvm-creator
+++ b/kvm-creator
@@ -23,19 +23,9 @@ UDEV_RULES_FILE="/etc/udev/rules.d/92-kvm_creator-%s.rules"
[ "$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] ] ]"
}
@@ -139,9 +129,7 @@ EOF
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"
}
@@ -149,7 +137,7 @@ EOF
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
diff --git a/kvm-manager b/kvm-manager
index 6ba3629..3e575c6 100755
--- a/kvm-manager
+++ b/kvm-manager
@@ -9,9 +9,7 @@ set -e
## 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
@@ -21,6 +19,10 @@ if [ -z "$VMNAME" ] ; then
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: )