From 62f45b6780ebf2ca3186dbe2c33b75cf8c520357 Mon Sep 17 00:00:00 2001 From: Matt Churchyard Date: Sat, 16 Apr 2016 08:08:18 +0100 Subject: [PATCH] Standadise VERSION_ vars and start on function names --- lib/vm-rctl | 9 +++------ lib/vm-run | 8 ++++---- vm | 6 +++--- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/vm-rctl b/lib/vm-rctl index 598aacc..93b0711 100644 --- a/lib/vm-rctl +++ b/lib/vm-rctl @@ -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 diff --git a/lib/vm-run b/lib/vm-run index a331ab6..d966fa4 100644 --- a/lib/vm-run +++ b/lib/vm-run @@ -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 } diff --git a/vm b/vm index 9675417..ae6cfa4 100644 --- a/vm +++ b/vm @@ -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