aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-12-28 15:19:20 -0200
committerSilvio Rhatto <rhatto@riseup.net>2016-12-28 15:19:20 -0200
commit5400b771c80926f6bda9c1bae72d72d2c0e1055a (patch)
treea3cd7fcfd740dee571ad01e622ae088962fcd06c
parentae0ab5044d84b553f29aa7159adcbc74b04a9fba (diff)
downloadvbox-5400b771c80926f6bda9c1bae72d72d2c0e1055a.tar.gz
vbox-5400b771c80926f6bda9c1bae72d72d2c0e1055a.tar.bz2
Support for multiple actions at kvmx
-rwxr-xr-xkvmx34
1 files changed, 19 insertions, 15 deletions
diff --git a/kvmx b/kvmx
index f83fecc..1208dce 100755
--- a/kvmx
+++ b/kvmx
@@ -8,7 +8,8 @@ BASENAME="`basename $0`"
STORAGE="/var/cache/qemu"
SHARED="/var/data/load"
PORT="$(($RANDOM + 1024))"
-VM="$1"
+ACTION="$1"
+VM="$2"
# Check
if [ -z "$VM" ]; then
@@ -19,20 +20,23 @@ elif [ ! -e "$STORAGE/$VM.img" ]; then
exit 1
fi
-# Run virtual machine
-kvm -m 2048 -name $VM -drive file=$STORAGE/$VM.img,if=virtio -vga qxl \
- -spice port=$PORT,addr=127.0.0.1,disable-ticketing,streaming-video=off,jpeg-wan-compression=never,playback-compression=off,zlib-glz-wan-compression=never,image-compression=off \
- -device virtio-serial-pci \
- -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 \
- -chardev spicevmc,id=spicechannel0,name=vdagent \
- -smp 2 -soundhw ac97 -cpu host -balloon virtio \
- -fsdev local,id=$VM,path=$SHARED,security_model=none -device virtio-9p-pci,fsdev=$VM,mount_tag=$VM &
+# Dispatch
+if [ "$ACTION" == "up" ]; then
+ # Run virtual machine
+ kvm -m 2048 -name $VM -drive file=$STORAGE/$VM.img,if=virtio -vga qxl \
+ -spice port=$PORT,addr=127.0.0.1,disable-ticketing,streaming-video=off,jpeg-wan-compression=never,playback-compression=off,zlib-glz-wan-compression=never,image-compression=off \
+ -device virtio-serial-pci \
+ -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 \
+ -chardev spicevmc,id=spicechannel0,name=vdagent \
+ -smp 2 -soundhw ac97 -cpu host -balloon virtio \
+ -fsdev local,id=$VM,path=$SHARED,security_model=none -device virtio-9p-pci,fsdev=$VM,mount_tag=$VM &
-# Run spice client
-spicec --host localhost --port $PORT &
+ # Run spice client
+ spicec --host localhost --port $PORT &
-# Give time to boot
-sleep 5
+ # Give time to boot
+ sleep 5
-# Fix window titles
-xdotool search --name "SPICEc:0" set_window --name $VM
+ # Fix window titles
+ xdotool search --name "SPICEc:0" set_window --name $VM
+fi