]> gitweb.fluxo.info Git - kvm-manager.git/commitdiff
removed TAP and MAC arguments from kvm-creator, and updated README to reflect the...
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Mon, 6 Jun 2011 23:07:01 +0000 (19:07 -0400)
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Mon, 6 Jun 2011 23:07:01 +0000 (19:07 -0400)
Changelog [new file with mode: 0644]
README
kvm-creator
kvm-manager

diff --git a/Changelog b/Changelog
new file mode 100644 (file)
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 923df4b5ff85a9dbb46440721dc18ed6eace23f6..2f9b01213093c17483c54c971bf72e24a89e4181 100644 (file)
--- 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.
index 541d32c6243aa4c805a2123f653e21c30b4b4beb..8d2afa7e76d0bc0e1e022c9e1e421831cb0dc91c 100755 (executable)
@@ -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
 
index 6ba362977df0894b4575f03e5c120399b3d353f0..3e575c6515adde3ce34ceb45d5291e61d1813441 100755 (executable)
@@ -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: )