From 75fc77c650f092b9b0d781995762db3c5cfd007a Mon Sep 17 00:00:00 2001 From: rodrigc Date: Wed, 24 Sep 2014 07:29:07 +0000 Subject: MFC r271447, r271496 - Attach the ISO to an ahci-cd emulated device - Propagate the error status of /usr/sbin/bhyve Approved by:re (delphij) --- share/examples/bhyve/vmrun.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'share/examples') diff --git a/share/examples/bhyve/vmrun.sh b/share/examples/bhyve/vmrun.sh index 793a63d..f7bb2a0 100755 --- a/share/examples/bhyve/vmrun.sh +++ b/share/examples/bhyve/vmrun.sh @@ -196,7 +196,7 @@ while [ 1 ]; do exit 1 fi BOOTDISK=${isofile} - installer_opt="-s 31:0,virtio-blk,${BOOTDISK}" + installer_opt="-s 31:0,ahci-cd,${BOOTDISK}" else BOOTDISK=${virtio_diskdev} installer_opt="" @@ -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