Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Sep 2014 05:08:35 +0000 (UTC)
From:      Craig Rodrigues <rodrigc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r271496 - head/share/examples/bhyve
Message-ID:  <201409130508.s8D58Z0S085702@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rodrigc
Date: Sat Sep 13 05:08:35 2014
New Revision: 271496
URL: http://svnweb.freebsd.org/changeset/base/271496

Log:
  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

Modified:
  head/share/examples/bhyve/vmrun.sh

Modified: head/share/examples/bhyve/vmrun.sh
==============================================================================
--- head/share/examples/bhyve/vmrun.sh	Sat Sep 13 03:10:02 2014	(r271495)
+++ head/share/examples/bhyve/vmrun.sh	Sat Sep 13 05:08:35 2014	(r271496)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409130508.s8D58Z0S085702>