#!/bin/sh guestdisk=fbsd-udbc.raw vmname=$(basename $guestdisk .raw)-$(hostname) xhcidev="0/20/0" pcidev="pci0:$(echo $xhcidev | sed -e 's/\//:/g')" guestIF=tap0 bhyve=bhyve bhyve=/usr/obj/usr/src/amd64.amd64/usr.sbin/bhyve/bhyve vmm=bhyve if [ "$1" == "qemu" ] then shift vmm="qemu" fi if [ "$1" != "nopass" ] then passthru="-s 7,passthru,${xhcidev}" driver=$(pciconf -l pci0:0:20:0 | awk -F '\@' '{ print $1}' | sed 's/[0-9]//g') if [ "$driver" != "ppt" ] then echo changing driver from $driver to ppt for pcidev $pcidev devctl detach $pcidev devctl set driver $pcidev ppt fi else passthru="" fi if [ "$1" == "debug" ] then shift if [ "$1" == "wait" ] then bhyveflags="-G w0.0.0.0:1234" qemuflags="-gdb tcp:0.0.0.0:1234 -S" shift else bhyveflags="-G 0.0.0.0:1234" qemuflags="-gdb tcp:0.0.0.0:1234" fi fi if [ -e /dev/vmm/$vmname ] then echo "removing existing instance of $vmname" bhyvectl --destroy --vm=fbsd-udbc-iwx-test fi if [ "$(uname)" == "FreeBSD" ] then echo "updating loader" sudo sh /home/tj/vms/udbc/updateloader.sh echo "starting vm: ${vmname} on ${vmm}" sleep 1 if [ "$vmm" == "qemu" ] then qemu-system-x86_64 \ -display none \ -smp 4 \ -m 2048 \ --bios /usr/local/share/edk2-qemu/QEMU_UEFI-x86_64.fd \ $qemuflags \ -device virtio-serial-pci \ -serial mon:stdio \ -monitor telnet:localhost:4322,server,nowait \ -net nic \ -net user,hostfwd=tcp::2222-:22 \ -drive file=${guestdisk},format=raw,if=virtio else while true do $bhyve $bhyveflags \ -c 4 \ -m 512 \ -wH \ -S \ -s 0,hostbridge \ -s 4,ahci-hd,${guestdisk} \ -s 5,virtio-net,${guestIF} \ $passthru \ -s 29,fbuf,tcp=0.0.0.0:5900,w=1920,h=1080,nowait \ -s 31,lpc \ -l com1,stdio \ -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \ ${vmname} #-s 30,xhci,tablet \ if [ $? -ne 0 ] then exit fi done fi # vmpid=$! fi #echo waiting for $vmpid #wait $vmpid bhyvectl --vm=${vmname} --destroy