vmstart (1027B)
1 #!/bin/sh 2 3 usage() 4 { 5 echo "usage: ${0##*/} [-u] [-c cpu] [-C com] [-d disk] [-i img] [-m mem] [-t tap] name" 1>&2 6 exit 1 7 } 8 9 cpu="2" 10 mem="2G" 11 disk="disk.img" 12 tap="tap0" 13 14 # TODO: opt: disname, lpc, xhci 15 while getopts c:C:d:i:m:t:u arg; do 16 case "${arg}" in 17 c) cpu="${OPTARG}" ;; 18 C) com="${OPTARG}" ;; 19 d) disksiz="${OPTARG}" ;; 20 i) img="${OPTARG}" ;; 21 m) mem="${OPTARG}" ;; 22 t) tap="${OPTARG}" ;; 23 u) uefi="-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd" ;; 24 *) usage ;; 25 esac 26 done 27 shift $((OPTIND - 1)) 28 29 name="${1}" 30 test -z "${name}" && usage 31 32 test -n "${disksiz}" && truncate -s "${disksiz}" ${disk} 33 ifconfig "${tap}" up 34 35 bhyve -c ${cpu} -m ${mem} -wH \ 36 -s 0,hostbridge \ 37 `test -n "${img}" && echo "-s 3,ahci-cd,${img}"` \ 38 -s 4,ahci-hd,${disk} \ 39 -s 5,virtio-net,${tap} \ 40 -s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600,wait \ 41 -s 30,xhci,tablet \ 42 -s 31,lpc \ 43 `test -n "${com}" && echo "-l com1,${com}"` \ 44 `test -n "${uefi}" && echo ${uefi}` \ 45 ${name} 46