diff options
author | rodrigc <rodrigc@FreeBSD.org> | 2014-09-13 05:08:35 +0000 |
---|---|---|
committer | rodrigc <rodrigc@FreeBSD.org> | 2014-09-13 05:08:35 +0000 |
commit | 0e1107608cf95a171f93faed56157d2200a7ad62 (patch) | |
tree | 82a2ba0f17c1edffcfc5dc7fd388013c5dadeb79 /share/examples | |
parent | 9741565697f0298e329856550a52c1c7e3c30d7d (diff) | |
download | FreeBSD-src-0e1107608cf95a171f93faed56157d2200a7ad62.zip FreeBSD-src-0e1107608cf95a171f93faed56157d2200a7ad62.tar.gz |
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
Diffstat (limited to 'share/examples')
-rwxr-xr-x | share/examples/bhyve/vmrun.sh | 17 |
1 files changed, 14 insertions, 3 deletions
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 |