bhyve_exit=$?
# bhyve returns the following status codes:
# 0 - VM has been reset
# 1 - VM has been powered off
# 2 - VM has been halted
# 3 - VM generated a triple fault
# all other non-zero status codes are errors
#
if [ $bhyve_exit -ne 0 ]; then
break
fi
while(1) loop in the above script is a good start.#!/bin/sh
while [ 1 ]; do
/usr/sbin/bhyveload -m 4096 -d /usr/vm/tc_cache/tc_cache.img tc_cache
/usr/sbin/bhyve -c 4 -m 4096 -A -H -P \
-s 2:0,virtio-blk,/usr/vm/tc_cache/tc_cache.img \
-s 2:1,virtio-blk,/san/tc_cache/tc_cache.img \
-s 3:2,passthru,3/0/3 \
-s 31,lpc -l com1,stdio \
tc_cache
bhyve_exit=$?
if [ $bhyve_exit -ne 0 ]; then
break
fi
done
/usr/sbin/bhyvectl --destroy --vm=tc_cache