mirror of
https://github.com/churchers/vm-bhyve.git
synced 2025-12-11 17:30:23 +01:00
Few fixes to multi-guest stop command
This commit is contained in:
33
lib/vm-core
33
lib/vm-core
@@ -413,24 +413,25 @@ __vm_stop(){
|
||||
[ -z "${_name}" ] && __usage
|
||||
|
||||
while [ -n "${_name}" ]; do
|
||||
[ ! -e "/dev/vmm/${_name}" ] && __err "${_name} doesn't appear to be a running virtual machine"
|
||||
|
||||
_pid=$(pgrep -fx "bhyve: ${_name}")
|
||||
_loadpid=$(pgrep -fl "grub-bhyve|bhyveload" | grep " ${_name}\$" |cut -d' ' -f1)
|
||||
|
||||
if [ -n "${_pid}" ]; then
|
||||
echo "Sending poweroff to ${_name}"
|
||||
kill "${_pid}"
|
||||
elif [ -n "${_loadpid}" ]; then
|
||||
if __confirm "Guest is in bootloader stage, do you wish to force exit"; then
|
||||
echo "Killing ${_name}"
|
||||
kill "${_loadpid}"
|
||||
bhyvectl --destroy --vm=${_name} >/dev/null 2>&1
|
||||
fi
|
||||
if [ ! -e "/dev/vmm/${_name}" ]; then
|
||||
__warn "${_name} doesn't appear to be a running virtual machine"
|
||||
else
|
||||
__warn "unable to locate process id for this virtual machine"
|
||||
fi
|
||||
_pid=$(pgrep -fx "bhyve: ${_name}")
|
||||
_loadpid=$(pgrep -fl "grub-bhyve|bhyveload" | grep " ${_name}\$" |cut -d' ' -f1)
|
||||
|
||||
if [ -n "${_pid}" ]; then
|
||||
echo "Sending ACPI shutdown to ${_name}"
|
||||
kill "${_pid}"
|
||||
elif [ -n "${_loadpid}" ]; then
|
||||
if __confirm "Guest ${_name} is in bootloader stage, do you wish to force exit"; then
|
||||
echo "Killing ${_name}"
|
||||
kill "${_loadpid}"
|
||||
bhyvectl --destroy --vm=${_name} >/dev/null 2>&1
|
||||
fi
|
||||
else
|
||||
__warn "unable to locate process id for ${_name}"
|
||||
fi
|
||||
fi
|
||||
shift
|
||||
_name="$1"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user