Skip to content

Commit

Permalink
Fix #22 - allow 'vm stop' to stop guest stuck in bootloader
Browse files Browse the repository at this point in the history
  • Loading branch information
churchers committed Nov 2, 2015
1 parent 96ca9a6 commit ba95bc4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions lib/vm-core
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,23 @@ __vm_start(){
#
__vm_stop(){
local _name="$1"
local _pid
local _pid _loadpid

[ -z "${_name}" ] && __usage
[ ! -e "/dev/vmm/${_name}" ] && __err "${_name} doesn't appear to be a running virtual machine"

_pid=$(pgrep -fx "bhyve: ${_name}")
[ -z "${_pid}" ] && __err "unable to locate process id for this virtual machine"

kill "${_pid}"
_loadpid=$(pgrep -fl "grub-bhyve|bhyveload" | grep " ${_name}\$" |cut -d' ' -f1)

if [ -n "${_pid}" ]; then
kill "${_pid}"
elif [ -n "${_loadpid}" ]; then
__confirm "Guest is in bootloader stage, do you wish to force exit" || exit 0
kill "${_loadpid}"
bhyvectl --destroy --vm=${_name} >/dev/null 2>&1
else
__err "unable to locate process id for this virtual machine"
fi
}

# 'vm reset'
Expand Down
2 changes: 1 addition & 1 deletion vm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

VERSION=0.9.5
VERSION=0.9.6
PATH=${PATH}:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
BSD_VERSION=$(uname -K)

Expand Down

0 comments on commit ba95bc4

Please sign in to comment.