Subject: [PATCH 1/3] vkernel: rc improvements

From: Rumko <[email-masked]>
Date: Sun, 10 Oct 2010 17:20:40 +0200

Add a vkernel_bin var that contains the default path to the binary,
for all the vkernels without a vkernel specific entry.
Also the root image is no longer required (diskless vkernels have no
use for a root image).
And when stopping a vkernel a pidfile is required so we don't kill
innocent bystanders.
---
 etc/defaults/rc.conf |    1 +
 etc/rc.d/vkernel     |   20 ++++++++------------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf
index 79b2dcd..683c4c6 100644
--- a/etc/defaults/rc.conf
+++ b/etc/defaults/rc.conf
@@ -457,6 +457,7 @@ jail_sysvipc_allow="NO"	# Allow SystemV IPC use from within a jail
 
 vkernel_enable="NO"	# Set to YES to enable starting of vkernels
 vkernel_list=""		# Space separated list of names of vkernels
+#vkernel_bin="/boot/kernel.VKERNEL"	# Default path to the vkernel binary
 
 #
 # Create an entry for each vkernel specified in vkernel_list
diff --git a/etc/rc.d/vkernel b/etc/rc.d/vkernel
index ef28133..35c8a43 100644
--- a/etc/rc.d/vkernel
+++ b/etc/rc.d/vkernel
@@ -27,12 +27,14 @@ vkernel_start()
 		# Configure vkernel binary
 		eval _bin=\"\${vkernel_${_vkernel}_bin}\"
 		if [ -z "${_bin}" -o ! -x "${_bin}" ]; then
-			echo
-			warn "Missing or undefined binary for vkernel '${_vkernel}'. Skipping."
-			continue
-		else
-			bin=${_bin}
+			eval _bin=\"\${vkernel_bin}\"
+			if [ -z "${_bin}" -o ! -x "${_bin}" ]; then
+				echo
+				warn "Missing or undefined binary for vkernel '${_vkernel}'. Skipping."
+				continue
+			fi
 		fi
+		bin=${_bin}
 
 		# Configure vkernel memory
 		eval _memsize=\"\$vkernel_${_vkernel}_memsize\"
@@ -48,8 +50,7 @@ vkernel_start()
 		eval _rootimgs=\"\${vkernel_${_vkernel}_rootimg_list}\"
 		if [ -z "${_rootimgs}" ]; then
 			echo
-			warn "No root image has been defined for vkernel '${_vkernel}'. Skipping."
-			continue
+			warn "No root image has been defined for vkernel '${_vkernel}'."
 		else
 			for _rootimg in ${_rootimgs}
 			do
@@ -86,11 +87,6 @@ vkernel_stop()
 		eval pidfile="/var/run/vkernel.${_vkernel}.pid"
 		if [ -f "${pidfile}" ]; then
 			eval pid=`cat ${pidfile}`
-		else
-			eval _bin=\"\${vkernel_${_vkernel}_bin}\"
-			if [ -n "$_bin" ]; then
-				eval pid=`ps auxwww | grep ${_bin} | grep -v grep | awk '{print $2}'`
-			fi
 		fi
 		if [ -z "${pid}" ]; then
 			warn "vkernel '${_vkernel}' not running?"
-- 
1.7.0.5