Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F158815630
D46250.id153829.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D46250.id153829.diff
View Options
diff --git a/libexec/rc/rc.d/bhyve b/libexec/rc/rc.d/bhyve
--- a/libexec/rc/rc.d/bhyve
+++ b/libexec/rc/rc.d/bhyve
@@ -250,7 +250,7 @@
# And separately record the setting of the non-bhyve_config(5) 'autostart'
# option in \$$bhyve_autostart_${vmname}.
#
- for vmcfgfile in $(command ls -1v ${bhyve_conf})
+ for vmcfgfile in $(command ls -1 ${bhyve_conf})
do
# $pervm_config_vars is a dash separated list (allowing cheap
# shell-internal checks) of bhyve-tree-config key names.
@@ -336,7 +336,7 @@
# If this non-bhyve_config(5) option is explicitly disabled, add the VM name
# to an exclusion list NOT to be stopped in case $bhyve_startvms=AUTO.
#
- for vmcfgfile in $(command ls -1v ${bhyve_conf})
+ for vmcfgfile in $(command ls -1 ${bhyve_conf})
do
# We only need to check if autostart is diasbled
pervm_config_vars="--autostart--name--"
@@ -451,6 +451,7 @@
then
echo "A zombie instance of VM \"${vm_name}\" was destroyed by" \
"bhyvectl(8)." >>${pervm_logfile}
+ sleep 1
else
# Clean the new logfile, --destroy is expected to fail.
true >${pervm_logfile}
@@ -510,7 +511,7 @@
'[ $? -ne 0 ] && break;' \
"done;" \
"command bhyvectl --destroy --vm=${vm_name}" \
- " >>${pervm_logfile} 2>&1."
+ " >>${pervm_logfile} 2>&1"
else
set -- "while true; do" \
"command bhyve ${bhyve_cmd_args} -k \"${vm_cfgfile}\"" \
@@ -536,8 +537,7 @@
sequential_vmstart()
{
local name vmname autostart namepid secondslapsed _sts _autostart_idx _startvms_idx _cfgf_idx=0 \
- re_bhpidnames_pat='^[[:blank:]]*([[:digit:]]{4,})[[:blank:]]+([^[:blank:]]*bhyve[:)[:blank:]].*)$'
- local pervm_logfile timeout=${bhyve_start_timeout}
+ re_bhpidname pervm_logfile timeout=${bhyve_start_timeout}
for vmname in ${configured_vmnames}
do
check_isstarted ${vmname}
@@ -600,7 +600,7 @@
unset element
if [ -n "$(eval echo \$bhyve_pid_${vmname})" ]; then
[ "${bhyve_startvms}" != AUTO ] &&
- startmsg "VM \"${vmname}\" is already started, ignoring!"
+ startmsg "VM \"${vmname}\" is already started."
continue
fi
if [ "$(eval echo \$bhyve_autostart_${vmname})" = FALSIFIED ]; then
@@ -620,6 +620,9 @@
for vmname in ${bhyve_ordered_startup}
do
+ re_bhpidname='^[[:blank:]]*([[:digit:]]{4,})[[:blank:]]+([^[:blank:]]*'
+ re_bhpidname="${re_bhpidname}"'bhyve[:)[:blank:]]+'"${vmname}"
+ re_bhpidname="${re_bhpidname}"')([[:blank:]].*$|$)'
# Our local $pervm_logfile is used in do_vm_spawn() too
pervm_logfile="${bhyve_vm_logdir}/bhyve-${vmname}.log"
msglineappend "${vmname} ("
@@ -639,7 +642,7 @@
secondslapsed=$(( $(command date +%s) - $_sts ))
while [ -z "$_vm_pid" ]; do
namepid=$(command ps -o pid= -o command= |\
- command sed -nE "s/${re_bhpidnames_pat}/\1:\2/p")
+ command sed -nE "s/${re_bhpidname}/\1:\2/p")
# Separator unconditionally is ':' following a [[:digit:]]
name="${namepid#*bhyve:[[:blank:]]}"
[ ${vmname} = "${name%%[[:blank:]]*}" ] &&
@@ -807,9 +810,8 @@
msglineappend "${vmname} (pid=${_pid}), waiting "
secondslapsed=0
+ _wt=$timeout
while [ $timeout -gt $secondslapsed ]; do
- _wt=$(( $timeout - $secondslapsed ))
- _bs=$(( ${#_wt} + 11 ))
if [ $secondslapsed -eq 0 ]; then
builtin kill -s TERM $_pid # Translates to ACPI poweroff
printf "${_wt} seconds..."
@@ -822,8 +824,10 @@
done
printf "${_wt} seconds..."
fi
+ # Calculate backspace count with current $_wt!
+ _bs=$(( ${#_wt} + 11 ))
sleep 1
- : $((secondslapsed+=1))
+ _wt=$(( $timeout - $((secondslapsed+=1)) ))
done
unset _wt _bs
if [ $timeout -gt $secondslapsed ]; then
@@ -837,8 +841,10 @@
'/^([[:blank:]]*[[:digit:]]+:)*'"${vmname}"'[[:blank:]]*$/d' \
"${bhyve_launchstate}"
else
- msgline "\r${vmname} not successfully shut down within" \
- "$secondslapsed seconds!"
+ msgline "\r${vmname} did NOT shut down within $secondslapsed" \
+ "seconds."
+ msgline "\rYou'll need to manually destroy ${vmname}, check ps(1)" \
+ "and VNC/nmdm console!"
# Don't remove VM-name from journal shut down wasn't confirmed to
# be successfull. Granting another attemt doesn't harm.
fi
@@ -846,5 +852,9 @@
} # sequential_stopvms()
+if ! startmsg '' >/dev/null 2>&1; then
+ startmsg() { msgline "$@"; }
+fi
+
run_rc_command "$1"
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jun 7, 7:52 AM (6 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33795831
Default Alt Text
D46250.id153829.diff (5 KB)
Attached To
Mode
D46250: Add rc(8) script and bhyve_config(5) examples to start and stop bhyve(8) on FreeBSD via service(8)
Attached
Detach File
Event Timeline
Log In to Comment