mirror of
https://github.com/churchers/vm-bhyve.git
synced 2025-12-11 09:20:17 +01:00
Allow guests to have a system priority using renice
This commit is contained in:
14
lib/vm-rctl
14
lib/vm-rctl
@@ -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 ] && \
|
||||
|
||||
Reference in New Issue
Block a user