diff options
-rwxr-xr-x | kvm-creator | 6 | ||||
-rwxr-xr-x | kvm-manager | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/kvm-creator b/kvm-creator index ff51243..8cb34fc 100755 --- a/kvm-creator +++ b/kvm-creator @@ -12,6 +12,7 @@ NAME="$1" VG="$2" SIZE="${3:-3G}" RAM="${4:-512}" +DISK="/dev/mapper/${VG}-${NAME}" [ "$CMD" == "create" ] && [ ! -d /etc/sv/kvm ] && mkdir /etc/sv/kvm @@ -60,7 +61,7 @@ validate() { [ "$?" -eq 0 ] && die "The group '$NAME' already exists." [ -d /home/"$NAME" ] && die "The directory '/home/$NAME' already exists." [ -d /etc/sv/kvm/"$NAME" ] && die "The directory '/etc/sv/kvm/$NAME' already exists." - [ -d /dev/mapper/${VG}-${NAME} ] && die "The logical volume $NAME already exists." + [ -e $DISK ] && die "The logical volume $NAME already exists." } @@ -101,13 +102,14 @@ EOF 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/KVMOPTS" } demo() { validate - for foo in NAME VG TAP RAM MAC SIZE ; do + for foo in NAME VG TAP RAM MAC SIZE DISK ; do echo "$foo : ${!foo}" done diff --git a/kvm-manager b/kvm-manager index 40972ce..078fcf3 100755 --- a/kvm-manager +++ b/kvm-manager @@ -52,7 +52,7 @@ up() { chpst -u "$OWNER" mv "$LOGNAME" "$LOGNAME".$(date +%F_%T%z|tr : .) fi - exec chpst -u "$OWNER:$OWNERGROUP:kvm" /usr/bin/screen -D -m -L -c /etc/screenrc.kvm-manager -S "$VMNAME" -t "$VMNAME" -s /bin/false /usr/bin/kvm $KVMARGS -nographic -name "$VMNAME" -m "$RAM" -net nic,"macaddr=$MAC" -net "tap,hostname=$VMNAME,ifname=$TAP,script=no,downscript=no" -no-reboot -serial stdio "/dev/mapper/${VGNAME}-$VMNAME" + exec chpst -u "$OWNER:$OWNERGROUP:kvm" /usr/bin/screen -D -m -L -c /etc/screenrc.kvm-manager -S "$VMNAME" -t "$VMNAME" -s /bin/false /usr/bin/kvm $KVMARGS -nographic -name "$VMNAME" -m "$RAM" -net nic,"macaddr=$MAC" -net "tap,hostname=$VMNAME,ifname=$TAP,script=no,downscript=no" -no-reboot -serial stdio "$KVMOPTS" } |