Standadise VERSION_ vars and start on function names

This commit is contained in:
Matt Churchyard
2016-04-16 08:08:18 +01:00
parent 54237aeb4e
commit 62f45b6780
3 changed files with 10 additions and 13 deletions

View File

@@ -25,15 +25,12 @@
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# 'vm _rctl'
# set limits to virtual machine
# this is the background process
#
# @param string _name the name of the guest to enable limits
#
__vm_set_rctl_limits(){
__rcrl_set_limits(){
local _pcpu _rbps _wbps _riops _wiops
local _pid _exit
local _pid
# get limit settings
__config_get "_pcpu" "limit_pcpu"
@@ -63,7 +60,7 @@ __vm_set_rctl_limits(){
fi
# at this point we can return if < FreeBSD 11
[ ${BSD_VERSION} -lt 1100000 ] && return 0
[ ${VERSION_BSD} -lt 1100000 ] && return 0
if [ -n "${_rbps}" ]; then
/usr/bin/rctl -a process:${_pid}:readbps:throttle=${_rbps} >/dev/null 2>&1

View File

@@ -91,7 +91,7 @@ __vm_run(){
# if uefi, make sure we have bootrom, then update options for uefi support
if __checkyesno "${_uefi}"; then
if [ ${BSD_VERSION} -lt 1002509 ]; then
if [ ${VERSION_BSD} -lt 1002509 ]; then
__log "guest" "${_name}" "uefi guests can only be run on FreeBSD 10.3 or newer"
exit 15
fi
@@ -121,7 +121,7 @@ __vm_run(){
# set utc time in opts if requested
if __checkyesno "${_utc}"; then
if [ ${BSD_VERSION} -ge 1002000 ]; then
if [ ${VERSION_BSD} -ge 1002000 ]; then
_opts="${_opts} -u"
else
__log "guest" "${_name}" "utc time requested but not available pre FreeBSD 10.2"
@@ -172,7 +172,7 @@ __vm_run(){
__log "guest" "${_name}" "starting bhyve"
# call rctl now as next line will block until bhyve exits
__vm_set_rctl_limits ${_name} &
__rctl_set_limits &
# actually run bhyve!
# we're already in the background so we just wait for it to exit
@@ -469,7 +469,7 @@ __vm_bhyve_device_passthru(){
_slot=$((_slot + 1))
# add wired memory for 10.3+
[ ${BSD_VERSION} -ge 1003000 ] && _opts="${_opts} -S" && _wiredmem="1"
[ ${VERSION_BSD} -ge 1003000 ] && _opts="${_opts} -S" && _wiredmem="1"
fi
}

6
vm
View File

@@ -25,9 +25,9 @@
# POSSIBILITY OF SUCH DAMAGE.
VERSION=1.0-beta
VERSION_INT=100001
VERSION_INT=100002
VERSION_BSD=$(uname -K)
PATH=${PATH}:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
BSD_VERSION=$(uname -K)
. /etc/rc.subr
load_rc_config "vm"
@@ -57,7 +57,7 @@ fi
# check environment
[ `id -u` -ne 0 ] && __err "virtual machines can only be managed by root"
[ ${BSD_VERSION} -lt 1000000 ] && __err "please upgrade to FreeBSD 10 or newer for bhyve support"
[ ${VERSION_BSD} -lt 1000000 ] && __err "please upgrade to FreeBSD 10 or newer for bhyve support"
# we should be enabled in rc.conf
# or call it using forcestart