diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index 127b05c..edeedbf 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -428,6 +428,30 @@ varsym_enable="NO" # Proccess /etc/varsym.conf watchdogd_enable="NO" # Start the software watchdog daemon ############################################################## +### VKernel options ######################################### +############################################################## + +vkernel_enable="NO" # Set to YES to enable starting of vkernels +vkernel_list="" # Space separated list of names of vkernels + +# +# Create an entry for each vkernel specified in vkernel_list +# replacing 'example' by the name of the vkernel. +# +#vkernel_example_bin="/usr/obj/usr/src/sys/VKERNEL/kernel.debug" + # Path to the vkernel binary +#vkernel_example_memsize="64m" + # Amount of memory for the vkernel +#vkernel_example_rootimg_list="/var/vkernel/rootimg.01" + # Space separated list of disk images +#vkernel_example_iface_list="auto:bridge0" + # Optional: space separated list network interfaces for the vkernel +#vkernel_example_logfile="/dev/null" + # Optional: path to the console log file +#vkernel_example_flags="-U" + # Optional: aditional flags to start the vkernel with + +############################################################## ### Define source_rc_confs, the mechanism used by /etc/rc.* ## ### scripts to source rc_conf_files overrides safely. ## ############################################################## diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile index 1d1421c..16f8f0c 100644 --- a/etc/rc.d/Makefile +++ b/etc/rc.d/Makefile @@ -22,7 +22,8 @@ FILES= DAEMON LOGIN NETWORKING SERVERS abi accounting addswap adjkerntz \ quota random rarpd rcconf.sh resident rndcontrol root route6d routed \ routing rpcbind rtadvd rtsold rwho sysdb savecore securelevel sendmail \ serial sppp sshd swap1 syscons sysctl syslogd timed ttys usbd \ - vinum virecover watchdogd ypbind yppasswdd ypserv ypset ypupdated \ + vinum virecover vkernel watchdogd \ + ypbind yppasswdd ypserv ypset ypupdated \ ypxfrd varsym FILESDIR= /etc/rc.d FILESMODE= ${BINMODE} diff --git a/etc/rc.d/vkernel b/etc/rc.d/vkernel new file mode 100644 index 0000000..4d0597e --- /dev/null +++ b/etc/rc.d/vkernel @@ -0,0 +1,94 @@ +#!/bin/sh +# +# $DragonFly$ +# + +# PROVIDE: vkernel +# REQUIRE: LOGIN NETWORKING + +. /etc/rc.subr + +name="vkernel" +rcvar=`set_rcvar` +start_cmd="vkernel_start" +stop_cmd="vkernel_stop" + +vkernel_start() +{ + echo -n 'Starting virtual kernels:' + for _vkernel in ${vkernel_list} + do + # Configure vkernel binary + eval _bin=\"\${vkernel_${_vkernel}_bin}\" + if [ -z "${_bin}" ]; then + echo + warn "No binary has been defined for vkernel '${_vkernel}'. Skipping." + continue + else + bin=${_bin} + fi + + # Configure vkernel memory + eval _memsize=\"\$vkernel_${_vkernel}_memsize\" + if [ -z "${_memsize}" ]; then + echo + warn "No memsize has been defined for vkernel '${_vkernel}'. Skipping." + continue + else + memsize="-m ${_memsize}" + fi + + # Configure vkernel root image(s) + eval _rootimgs=\"\${vkernel_${_vkernel}_rootimg_list}\" + if [ -z "${_rootimgs}" ]; then + echo + warn "No root image has been defined for vkernel '${_vkernel}'. Skipping." + continue + else + for _rootimg in ${_rootimgs} + do + eval rootimgs=\"${rootimgs} -r ${_rootimg}\" + done + fi + + # Configure optional vkernel network interface(s) + eval _ifaces=\"\${vkernel_${_vkernel}_iface_list}\" + if [ -n "${_ifaces}" ]; then + for _iface in ${_ifaces} + do + eval ifaces=\"${ifaces} -I ${_iface}\" + done + fi + + # Configure optional console logfile + eval logfile=\"\${vkernel_${_vkernel}_logfile}\" + [ -z "${logfile}" ] && logfile="/dev/null" + + # Configure optional flags + eval flags=\"\${vkernel_${_vkernel}_flags}\" + + eval "daemon ${bin} ${memsize} ${rootimgs} ${ifaces} ${flags} >>${logfile} 2>&1" + echo -n " ${_vkernel}" + done + echo '.' +} + +vkernel_stop() +{ + for _vkernel in ${vkernel_list} + do + eval _bin=\"\${vkernel_${_vkernel}_bin}\" + if [ -n "$_bin" ]; then + eval pid=`ps auxwww | grep ${_bin} | grep -v grep | awk '{print $2}'` + if [ -z "${pid}" ]; then + warn "vkernel '${_vkernel}' not running?" + else + eval kill -TERM ${pid} + fi + fi + done +} + + +load_rc_config $name +run_rc_command "$1" diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index f492617..c545d39 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -2668,6 +2668,35 @@ If set, start a watchdog timer in the background which will terminate if .Xr shutdown 8 has not completed within the specified time (in seconds). +.It Va vkernel_enable +.Pq Vt bool +If set to +.Dq Li NO , +any configured vkernels will not be started. +.It Va vkernel_list +.Pq Vt str +A space separated list of names for vkernels. +This is purely a configuration aid to help identify and +configure multiple vkernels. +The names specified in this list will be used to +identify settings common to a vkernel instance. +Assuming that the vkernel in question was named +.Li example , +you would have the following dependent variables +(filled with reference values in this text): +.Bd -literal +vkernel_example_bin="/usr/obj/usr/src/sys/VKERNEL/kernel.debug" +vkernel_example_memsize="64m" +vkernel_example_rootimg_list="/var/vkernel/rootimg.01" +vkernel_example_iface_list="auto:bridge0" +vkernel_example_logfile="/dev/null" +vkernel_example_flags="-U" +.Ed +.Pp +The last three are optional. +They default to an empty string if not set, except for logfile which defaults to +.Pa /dev/null +if it is not set. .El .Sh FILES .Bl -tag -width ".Pa /etc/defaults/rc.conf" -compact