changeset 467:6ecd16725818

Begin refactoring bhyve into fbhyve. Planned: - more consistent naming (analogous to jails) - using bhyve configuration files instead of RC variables for bhyve devices - more docs
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 14 Jun 2024 09:40:04 +0200
parents 4638f2f68b9d
children 3108ce603fa1
files docs/conf.py docs/man/index.rst docs/man/man8/fbhyve.rst docs/man/man8/local-bsdtools.rst files/fbhyve.in pkg-plist
diffstat 6 files changed, 62 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/docs/conf.py	Fri Jun 14 08:48:27 2024 +0200
+++ b/docs/conf.py	Fri Jun 14 09:40:04 2024 +0200
@@ -80,6 +80,7 @@
     ("man/man8/local-bsdtools", "local-bsdtools", 'FreeBSD administration helper tools v%s' % release, [author], 8),
     ("man/man8/bsmtp2dma", "bsmtp2dma", "Bacula compatible mail submission program", [author], 8),
     ("man/man8/check-ports", "check-ports", "Report the version status of installed packages and check for them also in repositories", [author], 8),
+    ("man/man8/fbhyve", "fbhyve", "Manage bhyve VMs (RC script)", [author], 8),
     ("man/man8/fjail", "fjail", "Management of jails", [author], 8),
     ("man/man8/fjail-configure", "fjail-configure", "Basic configuration of jails", [author], 8),
     #("man/man8/fjail-copy", "fjail-copy", "Recursively copy ZFS datasets including all properties", [author], 8),
--- a/docs/man/index.rst	Fri Jun 14 08:48:27 2024 +0200
+++ b/docs/man/index.rst	Fri Jun 14 09:40:04 2024 +0200
@@ -11,6 +11,7 @@
    man8/local-bsdtools
    man8/bsmtp2dma
    man8/check-ports
+   man8/fbhyve
    man8/fjail
    man8/fjail-configure
    man8/fjail-freebsd-update
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man/man8/fbhyve.rst	Fri Jun 14 09:40:04 2024 +0200
@@ -0,0 +1,40 @@
+.. -*- coding: utf-8; indent-tabs-mode: nil; -*-
+
+fbhyve
+======
+
+Synopsis
+--------
+
+**service fbhyve** [ **start** | **stop** | **poll** | **status** ] [**name**]...
+
+
+Description
+-----------
+
+An :file:`rc.d` script to start :manpage:`bhyve(8)` virtual machines
+
+
+Configuration Variables
+~~~~~~~~~~~~~~~~~~~~~~~
+
+`fbhyve_enable`
+  Default: NO
+
+`fbhyve_list`
+  The name of VMs to start to (aka. "profiles" or "sessions")
+
+
+Files
+-----
+
+- :file:`/usr/local/etc/fbhyve`
+
+    Default-directory where all the configuration files with relative
+    filenames are looked up.
+
+
+See also
+--------
+
+:manpage:`bhyve(8)`, :manpage:`rc.conf(5)`, :manpage:`tmux(1)`
--- a/docs/man/man8/local-bsdtools.rst	Fri Jun 14 08:48:27 2024 +0200
+++ b/docs/man/man8/local-bsdtools.rst	Fri Jun 14 09:40:04 2024 +0200
@@ -66,8 +66,10 @@
 
 - :manpage:`fpkg(8)`
 
+- :manpage:`fbhyve(8)`
+
 - :manpage:`fwireguard(8)`
-  
+
 - :manpage:`fzfs(8)`
 
   * :manpage:`fzfs-copy-tree(8)`
--- a/files/fbhyve.in	Fri Jun 14 08:48:27 2024 +0200
+++ b/files/fbhyve.in	Fri Jun 14 09:40:04 2024 +0200
@@ -1,14 +1,16 @@
 #!/bin/sh
 
-# PROVIDE: bhyve
+# PROVIDE: fbhyve
 # REQUIRE: LOGIN
-# KEYWORD: nojail
+# KEYWORD: shutdown nojail
 #
 
+# @(#)%%SIMPLEVERSIONTAG%%
+
 #
 # Add the following lines to /etc/rc.conf to enable bhyve:
-# bhyve_enable (bool):  Set to "NO" by default.
-#                       Set it to "YES" to enable bhyve
+# fbhyve_enable (bool):  Set to "NO" by default.
+#                        Set it to "YES" to enable bhyve
 # bhyve_profiles (str): Set to "" by default.
 #                       Define your profiles here.
 # bhyve_tapdev (str):   Set to "tap0" by default.
@@ -22,8 +24,8 @@
 
 . /etc/rc.subr
 
-name="bhyve"
-rcvar=bhyve_enable
+name="fbhyve"
+rcvar=fbhyve_enable
 
 start_precmd="bhyve_prestart"
 status_cmd="bhyve_status"
@@ -33,7 +35,6 @@
 command="/usr/local/bin/tmux"
 procname="-sh"
 
-[ -z "$bhyve_enable" ]  && bhyve_enable="NO"
 [ -z "$bhyve_tapdev" ]  && bhyve_tapdev="tap0"
 [ -z "$bhyve_diskdev" ] && bhyve_diskdev="none"
 [ -z "$bhyve_ncpu" ]    && bhyve_ncpu="1"
@@ -41,11 +42,15 @@
 
 load_rc_config $name
 
+: {fbhyve_enable:="NO"}
+: {fbhyve_configdir:="%%PREFIX%%/etc/fbhyve"}
+
+
 if [ -n "$2" ]; then
 	profile="$2"
 	_session="${_session}_${profile}"
 	if [ "x${bhyve_profiles}" != "x" ]; then
-		eval bhyve_enable="\${${_session}_enable:-${bhyve_enable}}"
+		eval fbhyve_enable="\${${_session}_enable:-${fbhyve_enable}}"
 		eval bhyve_tapdev="\${${_session}_tapdev:-${bhyve_tapdev}}"
 		eval bhyve_diskdev="\${${_session}_diskdev:-${bhyve_diskdev}}"
 		eval bhyve_ncpu="\${${_session}_ncpu:-${bhyve_ncpu}}"
@@ -57,7 +62,7 @@
 	if [ "x${bhyve_profiles}" != "x" -a "x$1" != "x" ]; then
 		for profile in ${bhyve_profiles}; do
 			eval _enable="\${bhyve_${profile}_enable}"
-			case "x${_enable:-${bhyve_enable}}" in
+			case "x${_enable:-${fbhyve_enable}}" in
 			x|x[Nn][Oo]|x[Nn][Oo][Nn][Ee])
 				continue
 				;;
@@ -65,12 +70,12 @@
 				;;
 			*)
 				if test -z "$_enable"; then
-					_var=bhyve_enable
+					_var=fbhyve_enable
 				else
 					_var=bhyve_"${profile}"_enable
 				fi
 				echo "Bad value" \
-				    "'${_enable:-${bhyve_enable}}'" \
+				    "'${_enable:-${fbhyve_enable}}'" \
 				    "for ${_var}. " \
 				    "Profile ${profile} skipped."
 				continue
--- a/pkg-plist	Fri Jun 14 08:48:27 2024 +0200
+++ b/pkg-plist	Fri Jun 14 09:40:04 2024 +0200
@@ -18,6 +18,7 @@
 %%DOCS%%share/man/man8/local-bsdtools.8.gz
 %%DOCS%%share/man/man8/bsmtp2dma.8.gz
 %%DOCS%%share/man/man8/check-ports.8.gz
+%%DOCS%%share/man/man8/fbhyve.8.gz
 %%DOCS%%share/man/man8/fjail.8.gz
 %%DOCS%%share/man/man8/fjail-configure.8.gz
 %%DOCS%%share/man/man8/fjail-freebsd-update.8.gz