The attached patch contains two bhyve_config(5) examples due to the design of the actual extension,
which is a /etc/rc.d/bhyve script to start and stop VMs utilizing service(8) (and at boot/shutdown).
bhyve_config(5) is a powerful contribution to bhyve(8) which makes it easy to configure VMs to be run on FreeBSD.
Unfortunately I had to start them via 'rc.local' hack which is very inconvenient, especially compared to how we can handle jails with 'service jail'.
Initial goal was to have 'service bhyve' as user-friendly as jail is - it simply does what user expects for the start and stop commands.
rc.conf(5) variables are mostly optional:
- User has to enable auto-start with bhyve_enable="YES".
- bhyve_cfgdir is /etc/bhyve_config.d by default.
- bhyve_startvms is optional and defaults to AUTO, which means that every VM defined by a config file in $bhyve_cfgdir will be started and stopped at boot/shutdown. Start order in AUTO mode is determined from lexographically sorting file names, stop order by parsing (and altering) the lauchstate file (in /var/run/bhyve, which is in mtree/BSD.var.dist). If defined, bhyve_startvms limits starting/stopping VMs to the listed names and strictly defines the order of starting up / shutting down.
- there are currently three cross-referencing variables supported: bhyve_vmdisk_default_pool bhyve_vmdisk_default_dataset and bhyve_vmdisk_default_imagedir They can be referenced in bhyve_config(5) files without the bhyve_ prefix (as %(bhyve_vmdisk_default_imagedir) e.g.)
- bhyve_stop_any is present for people who want a 'killall' feature.
- bhyve_unreversed_stop is superfluous in my opinion, but users might expect such a switch which they know from jail.
- bhyve_start_timeout and bhyve_stop_timeout can be adjusted on demand
Only sequential starting/stopping is currently supported.
If bhyve_startvms is not AUTO and 'autostart' was disabled for a listed VM, a console message is printed. Likewise if user tries to start a already started VM via CLI provided VM name e.g. In default AUTO mode, no informal messages are printed.
bhyveload(8) is supported as well as booting with lpc.bootrom defined (UEFI).
rc.conf(5) man page update is missing currently, I'm not used to mdoc(7), but I'm happy to provide a diff too in case this diff is considered to be a realistic commit candidate.
I'm unsure how the non-bhyve_cfg(5) key/variable 'autostart' is to be documented. For cold-standby VMs e.g. it is important that we can exclude configured machines from being started automatically. Since bhyve_cfg(5) explicitly allows using private variables, I made use of it. But I think mentioning it in bhyve_cfg(5) is wrong.
Same applies to the 'bhyveload_hba' script-private variable.