# HG changeset patch # User Matthias Förste # Date 1473170847 -7200 # Node ID f10fa2b7fc440de123762a8617c7d7015b79bfdd # Parent 9fac1b9871d9a41842eaa5efc8c8b33d8925d39d some fixes diff -r 9fac1b9871d9 -r f10fa2b7fc44 kvmtool.sh --- a/kvmtool.sh Wed Jan 11 14:08:28 2012 +0100 +++ b/kvmtool.sh Tue Sep 06 16:07:27 2016 +0200 @@ -6,11 +6,12 @@ ME=${0##*/} NODE=$(uname -n) KVMTAB=/etc/kvmtab -KVM_OPTS_BUILTIN='-drive file=/dev/drbd$ID,cache=none,aio=native,if=virtio,index=0,boot=on - -boot c +KVM_OPTS_BUILTIN='-drive file=/dev/drbd$ID,cache=none,aio=native,if=virtio,index=0 + -boot order=c -m 512 -net nic,macaddr=$MAC,model=virtio - -net tap,ifname=tap$ID,script=no' + -net tap,ifname=tap$ID,script=no + -k de' function die() { echo $0: "$@" >&2; exit 1; } @@ -66,6 +67,8 @@ echo system_powerdown | nc 0 $MONITOR ip link set tap$ID down brctl delif br0 tap$ID + # 'device is held open by someone' :( + sleep 1 echo "switch drbd$ID into secondary role" drbdadm secondary drbd$ID ;; @@ -106,13 +109,13 @@ done -# When called as "kvmtool", just try to start -# all the vm's we find in /etc/kvmtab, except, there -# are more parameters on the command line +# "kvmtool start" or "kvmtool start all" will try to start +# all the vm's we find in /etc/kvmtab; if called "kvmtool start " it +# will try to start the the vm called 'vm' if [[ "$ME" == *$ME ]]; then cmd="$1"; shift - if test $# = 0; then + if test $# = 0 || ( test $# = 1 && test $1 = 'all' ); then vms=$(egrep "^[[:alnum:]_-]+[[:space:]]+$NODE\b" $KVMTAB | tr -s '\t ' ' ' | cut -f1 -d' ') else vms="$@" @@ -143,9 +146,10 @@ =head1 DESCRIPTION This small tool helps to start the virtual machines known in F. -If just called as C it starts all machines that should run on the -current host. If called as C, it tries to start machine C, but -this may fail, if the F lists this machine for another host. +If just called as C or C it starts all +machines that should run on the current host. If called as C, it tries to start machine C, but this may fail, if the F +lists this machine for another host. =head1 OPTIONS