Few fixes to multi-guest stop command

This commit is contained in:
Matt Churchyard
2016-04-16 08:13:16 +01:00
parent 62f45b6780
commit 2c004adcdc
2 changed files with 18 additions and 17 deletions

View File

@@ -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

2
vm
View File

@@ -25,7 +25,7 @@
# POSSIBILITY OF SUCH DAMAGE.
VERSION=1.0-beta
VERSION_INT=100002
VERSION_INT=100003
VERSION_BSD=$(uname -K)
PATH=${PATH}:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin