mirror of
https://github.com/churchers/vm-bhyve.git
synced 2026-01-03 11:38:31 +01:00
Centralise console (currently nmdm) creation
This commit is contained in:
38
lib/vm-core
38
lib/vm-core
@@ -133,15 +133,7 @@ __vm_install(){
|
|||||||
[ ! -f "${vm_dir}/.iso/${_iso}" ] && __err "unable to find iso ${vm_dir}/.iso/${_iso}"
|
[ ! -f "${vm_dir}/.iso/${_iso}" ] && __err "unable to find iso ${vm_dir}/.iso/${_iso}"
|
||||||
[ ! -f "${_conf}" ] && __err "${_name} does not seem to be a valid virtual machine"
|
[ ! -f "${_conf}" ] && __err "${_name} does not seem to be a valid virtual machine"
|
||||||
|
|
||||||
# loop until we find an available nmdm
|
_com=$(__vm_create_console)
|
||||||
# using -e seemed to create devices so now scanning ls
|
|
||||||
while [ 1 ]; do
|
|
||||||
_ls=$(ls -1 /dev | grep "nmdm${_num}A")
|
|
||||||
[ -z "${_ls}" ] && break
|
|
||||||
_num=$(($_num + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
_com="nmdm${_num}A"
|
|
||||||
_memory=$(sysrc -inqf "${_conf}" memory)
|
_memory=$(sysrc -inqf "${_conf}" memory)
|
||||||
_guest=$(sysrc -inqf "${_conf}" guest)
|
_guest=$(sysrc -inqf "${_conf}" guest)
|
||||||
_disk=$(sysrc -inqf "${_conf}" disk0_name)
|
_disk=$(sysrc -inqf "${_conf}" disk0_name)
|
||||||
@@ -239,16 +231,7 @@ __vm_start(){
|
|||||||
[ -z "${_name}" ] && __usage
|
[ -z "${_name}" ] && __usage
|
||||||
[ ! -f "${_conf}" ] && __err "${_name} does not seem to be a valid virtual machine"
|
[ ! -f "${_conf}" ] && __err "${_name} does not seem to be a valid virtual machine"
|
||||||
|
|
||||||
# loop until we find an available nmdm
|
_com=$(__vm_create_console)
|
||||||
# using -e seemed to create devices so now scanning ls
|
|
||||||
# we could move this to _run but now relying on this being in ps output for "vm console" command
|
|
||||||
while [ 1 ]; do
|
|
||||||
_ls=$(ls -1 /dev | grep "nmdm${_num}A")
|
|
||||||
[ -z "${_ls}" ] && break
|
|
||||||
_num=$(($_num + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
_com="nmdm${_num}A"
|
|
||||||
|
|
||||||
# run background process to actually start bhyve
|
# run background process to actually start bhyve
|
||||||
# this will run as long as vm is running, including restarting bhyve after guest reboot
|
# this will run as long as vm is running, including restarting bhyve after guest reboot
|
||||||
@@ -495,3 +478,20 @@ __vm_iso(){
|
|||||||
ls -1 "${vm_dir}/.iso"
|
ls -1 "${vm_dir}/.iso"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# create a new console for a vm
|
||||||
|
# for now we are using nmdm
|
||||||
|
__vm_create_console(){
|
||||||
|
local _ls
|
||||||
|
local _num=0
|
||||||
|
|
||||||
|
# loop until we find an available nmdm
|
||||||
|
# using -e seemed to create devices so now scanning ls
|
||||||
|
while [ 1 ]; do
|
||||||
|
_ls=$(ls -1 /dev | grep "nmdm${_num}A")
|
||||||
|
[ -z "${_ls}" ] && break
|
||||||
|
_num=$(($_num + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "nmdm${_num}A"
|
||||||
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ __switch_init(){
|
|||||||
# list switches, currently just from stored configuration
|
# list switches, currently just from stored configuration
|
||||||
__switch_list(){
|
__switch_list(){
|
||||||
local _switchlist _portlist _switch _port _vlan
|
local _switchlist _portlist _switch _port _vlan
|
||||||
local _id _format="%-19s %-19s %10s %-20s\n"
|
local _id _format="%-19s %-19s %-7s %-20s\n"
|
||||||
|
|
||||||
_switchlist=$(sysrc -inqf "${vm_dir}/.config/switch" switch_list)
|
_switchlist=$(sysrc -inqf "${vm_dir}/.config/switch" switch_list)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user