Index: /usr/src/share/examples/bhyve/vmrun.sh =================================================================== --- /usr/src/share/examples/bhyve/vmrun.sh +++ /usr/src/share/examples/bhyve/vmrun.sh @@ -239,6 +239,7 @@ ${installer_opt} \ ${vmname} + bhyve_exit=$? # bhyve returns the following status codes: # 0 - VM has been reset # 1 - VM has been powered off @@ -246,9 +247,11 @@ # 3 - VM generated a triple fault # all other non-zero status codes are errors # - if [ $? -ne 0 ]; then + if [ $bhyve_exit -ne 0 ]; then break fi done -exit 99 +${BHYVECTL} --vm=${vmname} --destroy > /dev/null 2>&1 + +exit $bhyve_exit