Allow guests to have a system priority using renice

This commit is contained in:
Matt Churchyard
2018-10-08 15:43:59 +01:00
parent f235a8ebbd
commit 0cf424198c
5 changed files with 24 additions and 7 deletions

View File

@@ -28,25 +28,29 @@
# set limits to virtual machine
# this is the background process
#
rctl::set_limits(){
rctl::set(){
local _pcpu _rbps _wbps _riops _wiops
local _pid
local _pid _pri
# get limit settings
config::get "_pri" "priority"
config::get "_pcpu" "limit_pcpu"
config::get "_rbps" "limit_rbps"
config::get "_wbps" "limit_wbps"
config::get "_riops" "limit_riops"
config::get "_wiops" "limit_wiops"
# return if there are no limits
[ -z "${_pcpu}${_rbps}${_wbps}${_riops}${_wiops}" ] && return 1
# wait till bhyve starts and get pid
sleep 1
_pid=$(pgrep -fx "bhyve: ${_name}")
[ -z "${_pid}" ] && return 1
# check for a priority
[ -n "${_pri}" ] && renice ${_pri} ${_pid} >/dev/null 2>&1
# return if there are no limits
[ -z "${_pcpu}${_rbps}${_wbps}${_riops}${_wiops}" ] && return 1
# see if rctl works
/usr/bin/rctl >/dev/null 2>&1
[ $? -ne 0 ] && \