From 0e1107608cf95a171f93faed56157d2200a7ad62 Mon Sep 17 00:00:00 2001 From: rodrigc Date: Sat, 13 Sep 2014 05:08:35 +0000 Subject: Propagate the error status of /usr/sbin/bhyve out of the vmrun.sh script. Clean up the /dev/vmm entry for this VM when vmrun.sh exits. Reviewed by: neel Phabric: D767 --- share/examples/bhyve/vmrun.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'share') diff --git a/share/examples/bhyve/vmrun.sh b/share/examples/bhyve/vmrun.sh index 889ad46..f7bb2a0 100755 --- a/share/examples/bhyve/vmrun.sh +++ b/share/examples/bhyve/vmrun.sh @@ -204,7 +204,8 @@ while [ 1 ]; do ${LOADER} -c ${console} -m ${memsize} -d ${BOOTDISK} ${loader_opt} \ ${vmname} - if [ $? -ne 0 ]; then + bhyve_exit=$? + if [ $bhyve_exit -ne 0 ]; then break fi @@ -239,6 +240,7 @@ while [ 1 ]; do ${installer_opt} \ ${vmname} + bhyve_exit=$? # bhyve returns the following status codes: # 0 - VM has been reset # 1 - VM has been powered off @@ -246,9 +248,18 @@ while [ 1 ]; do # 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 + +case $bhyve_exit in + 0|1|2) + # Cleanup /dev/vmm entry when bhyve did not exit + # due to an error. + ${BHYVECTL} --vm=${vmname} --destroy > /dev/null 2>&1 + ;; +esac + +exit $bhyve_exit -- cgit v1.1