aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-06-05 20:49:24 -0300
committerSilvio Rhatto <rhatto@riseup.net>2016-06-05 20:49:24 -0300
commitd8bd926096ecf6d8c38453b6752088b8a10ca3b7 (patch)
treeccd6cdb6b0eda449afcd8324b013ed3de32c37f9
parent56d05072e6225f95e523d735e3236e4461484a16 (diff)
downloadkvm-manager-d8bd926096ecf6d8c38453b6752088b8a10ca3b7.tar.gz
kvm-manager-d8bd926096ecf6d8c38453b6752088b8a10ca3b7.tar.bz2
Make coding style more uniform
-rw-r--r--TODO2
-rwxr-xr-xdi-maker11
-rwxr-xr-xkvm-creator17
-rwxr-xr-xkvm-manager31
-rwxr-xr-xkvm-status8
5 files changed, 27 insertions, 42 deletions
diff --git a/TODO b/TODO
index f10242a..e4b2a0a 100644
--- a/TODO
+++ b/TODO
@@ -25,7 +25,7 @@ TODO for KVM-Manager
* can we separate the privileges for the monitor from the privs for
the console?
- + * can we start up the console screen first, listening on a UNIX
+ * can we start up the console screen first, listening on a UNIX
socket, and then launch kvm with the console as a client instead
(so that it works the other way around)?
diff --git a/di-maker b/di-maker
index e24df35..c60c9a6 100755
--- a/di-maker
+++ b/di-maker
@@ -1,19 +1,17 @@
#!/bin/bash
-
+#
# Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
# Date: 2009-10-08
# License: GPL v3+
-
+#
+# depends on grub2
# usage:
# di-maker ISOFILE [FILE ...]
# make a new debian installer ISO, packing any additionally-supplied files into the initramfs directly
set -e
-# depends on grub2
-
# specify the first argument as the new installer image:
-
output="$1"
SUITE=${SUITE:-stable}
@@ -95,7 +93,6 @@ fi
mkdir -p "$WORKDIR/boot/grub"
-
cat > "$WORKDIR/boot/grub/grub.cfg" <<EOF
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
terminal_output serial
@@ -111,4 +108,4 @@ absoutput="$(readlink -f "$output")"
## no longer using genisoimage with grub2:
# genisoimage -R -input-charset utf-8 -b boot/grub/stage2_eltorito -no-emul-boot --boot-load-size 4 -boot-info-table "$WORKDIR"
-(cd "$WORKDIR" && grub-mkrescue --output="$absoutput" .)
+( cd "$WORKDIR" && grub-mkrescue --output="$absoutput" . )
diff --git a/kvm-creator b/kvm-creator
index 0864ebe..ffd2e89 100755
--- a/kvm-creator
+++ b/kvm-creator
@@ -1,10 +1,11 @@
#!/bin/bash
-#set -x
-
+#
# Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
# Date: 2009-10-08
# License: GPL v3+
+#set -x
+
CMD="$1"
shift
@@ -28,32 +29,25 @@ UDEV_RULES_FILE="/etc/udev/rules.d/92-kvm_creator-%s.rules"
[ "$CMD" == "create" ] && mkdir -p /etc/sv/kvm
usage() {
-
die "USAGE: kvm-creator create|destroy|demo guestname [volumegroup [disksize [ram] ] ]"
-
}
die() {
-
echo "$1"
exit_code=1
[ -n "$2" ] && exit_code="$2"
exit $exit_code
-
}
destroy() {
-
update-service --remove "/etc/sv/kvm/$NAME"
rm -rf "/etc/sv/kvm/$NAME"
deluser --remove-home "$NAME"
lvremove "$VG/$NAME"
rm -f "$(udevrulename "$NAME")"
-
}
validate() {
-
errors=""
# Make sure none of the pieces already exist.
@@ -70,7 +64,6 @@ validate() {
[ -e "$(udevrulename "$NAME")" ] && errors=$(printf "%s\n%s" "The udev rules file '$(udevrulename "$NAME")' already exists.") || :
[ -z "$errors" ] || die "$errors"
-
}
udevrule() {
@@ -95,7 +88,6 @@ udevrulename() {
}
create() {
-
set -e
validate
if [ "$CREATE_USER" = "yes" ]; then
@@ -139,16 +131,13 @@ EOF
echo "$NAME" > "/etc/sv/kvm/$NAME/env/VMNAME"
echo "$RAM" > "/etc/sv/kvm/$NAME/env/RAM"
echo "$DISK" > "/etc/sv/kvm/$NAME/env/HDA"
-
}
demo() {
-
validate
for foo in NAME VG SIZE RAM DISK ; do
echo "$foo : ${!foo}"
done
-
}
[ "$CMD" != "create" ] && [ "$CMD" != "destroy" ] && [ "$CMD" != "demo" ] && usage
diff --git a/kvm-manager b/kvm-manager
index 45c7d66..e14df40 100755
--- a/kvm-manager
+++ b/kvm-manager
@@ -1,7 +1,5 @@
#!/bin/bash
-
-set -e
-
+#
# Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
# Date: 2011-01-26
# License: GPL v3+
@@ -13,6 +11,8 @@ set -e
# SMP=2 # optional, specify number of CPUs
# HDA..HDZ=/path/to/disk # optional
+set -e
+
if [ -z "$VMNAME" ] ; then
exit 1
fi
@@ -45,14 +45,14 @@ up() {
BOOTCHOICE=c
if [ -e "$KERNEL" -a -e "$INITRD" ] ; then
- KVMARGS="-kernel $KERNEL -initrd $INITRD"
+ KVMARGS="-kernel $KERNEL -initrd $INITRD"
if [ "$CMDLINE" ]; then
KERNEL_CMDLINE="$CMDLINE"
fi
elif [ -e "$NETBOOT" ] ; then
- BOOTCHOICE=n
+ BOOTCHOICE=n
elif [ -e "$CDISO" ] && [ -e $(readlink -f "$CDISO") ] ; then
- KVMARGS="-cdrom $CDISO"
+ KVMARGS="-cdrom $CDISO"
BOOTCHOICE=d
fi
@@ -76,8 +76,8 @@ up() {
[ -z "$HDA" ] || KVMARGS="$KVMARGS -drive file=$HDA,if=virtio,cache=none,index=$index,format=raw$first_disk_extra_args"
# loop here on everything after HDA:
for disk in HD{B..Z}; do
- index=$(( $index + 1 ))
- [ \! -b "${!disk}" ] || KVMARGS="$KVMARGS -drive file=${!disk},if=virtio,cache=none,index=$index,format=raw"
+ index=$(( $index + 1 ))
+ [ \! -b "${!disk}" ] || KVMARGS="$KVMARGS -drive file=${!disk},if=virtio,cache=none,index=$index,format=raw"
done
if [ -e /usr/share/qemu/sgabios.bin ]; then
@@ -87,7 +87,7 @@ up() {
LOGNAME="$OWNERHOME/vms/$VMNAME/console"
ln -sfT "$LOGNAME" ./servicelog
if [ -e "$LOGNAME" ] ; then
- chpst -u "$OWNER" mv "$LOGNAME" "$LOGNAME".$(date +%F_%T%z|tr : .)
+ chpst -u "$OWNER" mv "$LOGNAME" "$LOGNAME".$(date +%F_%T%z|tr : .)
fi
MONITORNAME="$OWNERHOME/vms/$VMNAME/monitor.socket"
@@ -102,7 +102,7 @@ EOF
chpst -u "$OWNER:$OWNERGROUP:kvm" \
/usr/bin/kvm $KVMARGS \
-M "${MACHINE:-pc}" \
- ${KERNEL_CMDLINE:+-append "$KERNEL_CMDLINE"} \
+ ${KERNEL_CMDLINE:+-append "$KERNEL_CMDLINE"} \
-enable-kvm \
-nodefaults \
-nographic \
@@ -127,22 +127,21 @@ EOF
trap 'kvmsend system_powerdown; wait %1' TERM
trap 'kvmsend cont; wait %1' CONT
trap 'kill -s TERM %1' QUIT
- # use SIGINT instead of SIGSTOP for freezing the guest because
- # trapping SIGSTOP is undefined:
- # http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_28
+ # use SIGINT instead of SIGSTOP for freezing the guest because
+ # trapping SIGSTOP is undefined:
+ # http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_28
trap 'kvmsend stop; wait %1' INT
trap 'kill %1 ; kill %2' EXIT
wait %1
}
-
down() {
brctl delif "$BRIDGE" "$TAP"
ip link set "$TAP" down
ip tuntap del mode tap dev "$TAP"
-# no need to lock up the block device as well, since the owner might
-# prefer to manipulate the disk directly.
+ # no need to lock up the block device as well, since the owner might
+ # prefer to manipulate the disk directly.
}
log() {
diff --git a/kvm-status b/kvm-status
index 9a2c6fc..a715e8c 100755
--- a/kvm-status
+++ b/kvm-status
@@ -18,10 +18,10 @@ function convert_ram {
echo "SERVER RAM"
total_ram=0
for foo in $(ls $dir); do
- ram=$(cat $dir/$foo/env/RAM)
- convert_ram "$ram"
- echo "$foo $display_ram"
- total_ram=$(( $total_ram + $display_ram ))
+ ram=$(cat $dir/$foo/env/RAM)
+ convert_ram "$ram"
+ echo "$foo $display_ram"
+ total_ram=$(( $total_ram + $display_ram ))
done
echo "TOTAL $total_ram"
} | column -t