Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: f774edce28
Fetching contributors…

Cannot retrieve contributors at this time

executable file 55 lines (44 sloc) 1.196 kb
#!/bin/bash
#
# launcher script for qemu-kvm
#
# machines are sourced from a file which defines functions, each
# specifying options for the particular VM, for example:
#
# vm_beatbox() {
# cdrom="-cdrom $isoroot/archlinux-2011.05.08-core-x86_64.iso -boot d"
#
# opts=(-nographic)
# drives=(
# "-drive file=$imgroot/beatbox.1.qcow2,if=virtio"
# "-drive file=$imgroot/beatbox.2.qcow2,if=virtio"
# )
# }
#
### Paths ################################
declare -r isoroot=/mnt/Gluttony/iso
declare -r imgroot=/mnt/Haven/qemu-img
declare -r machines=$XDG_CONFIG_HOME/qemu/machines
### Defaults #############################
declare mem="-m 1024"
declare cpus="-smp 4"
declare net="-net vde -net nic,model=virtio"
### Launcher #############################
. "$machines"
while getopts 'c' flag; do
case $flag in
c) usecdrom=true ;;
esac
done
shift $(( OPTIND - 1 ))
if [[ -z $1 ]]; then
printf 'Available VMs:\n'
printf ' %s\n' $(sed -n 's/^vm_\([^(;$]\+\).*/\1/p' "$machines")
exit 0
fi
if ! type -t vm_$1 >/dev/null; then
printf 'unknown VM: %s\n' "$1"
exit 1
fi
vm_$1; shift
exec qemu-kvm "${opts[@]}" $cpus $mem ${drives[@]} $net ${usecdrom:+$cdrom} "$@"
Jump to Line
Something went wrong with that request. Please try again.