rc-style script for bhyve VM provisioning and management

Michael Gmelin freebsd at grem.de
Sun Nov 3 13:15:58 UTC 2013

On Sun, 03 Nov 2013 00:18:09 -0700
Michael Dexter <editor at callfortesting.org> wrote:

> Hello all from the FreeBSD 20th Anniversary Party in San Francisco,
> I have published a bhyve virtual machine provisioning and management
> framework to simplify the building and deploying of bhyve VMs during
> the run-up to the FreeBSD 10.0 release. As you may know, bhyve is
> rapidly finalizing for release in FreeBSD 10.0 and most features are
> finally becoming stable enough to document in a canonical manner.
> These scripts demonstrate the many opportunities for customization of
> bhyve deployments and will embrace features like OpenBSD and Linux
> support as soon as key components like the userland grub* arrive
> (currently in final testing). It will also demonstrate the use of pf
> to allow bhyve networking on wireless interfaces.
> It can be downloaded from:
> http://bhyve.org/bhyve-script.tar
> It works like a rc script but does not comply with the FreeBSD way. I
> am working with several developers to determine to what degree it
> should be compatible with existing frameworks like ezjail.
> ./vm0 will give the usage:
> usage (start|stop|load|boot|destroy|restart|list|debug
> mount|umount|jail|format|fetch|install|provision|wipe)
> Some routines like "provision" include steps like fetch (distribution
> sets), format (disk images or volumes) and install them.
> The "jail" routine demonstrates how a virtual machine can be launched
> using the jail(8) command, because we can, given that bhyve FreeBSD
> VMs are simply instances of FreeBSD with the ABI limitations of
> different releases. bhyve will support any vision of FreeBSD with
> VirtIO, specifically FreeBSD 8.4 and 8-STABLE, 9.2 and 9-STABLE, and
> any recent version of 10 or 11.
> Detailed instructions are included in the vm0 script and it is
> designed to simply be copied to vm1, vm2 etc. with easily-configured
> global variables.
> While tmux(1) is optional and supports both captive and detached
> execution, a script is included to list and attach to running
> VMs/sessions. A script is also provided for the easy duplication of
> VMs and I have tested this with up to 15 X 16 vCPU instances though
> far more should work without issue.
> Please throw everything you can at bhyve to expose any remaining flaws
> prior to the FreeBSD 10.0 release.
> All the best,
> Michael Dexter

Sounds similar to how I ran my VMs for a while (well, I ln -s from the
original VM script instead of copying, so it's easier to update all at
once). I finally changed the script to use profiles a few days ago,
since it seemed much cleaner in general and better for automatic control
and also complies to the FreeBSD way. I submitted a PR for
sysutils/bhyve-rc literally hours before you released vm0
(http://www.freebsd.org/cgi/query-pr.cgi?pr=183604), great timing ;)
It's only good for one use case, but does that very well.

I like the idea of the script using the general structure of ezjail. I
would also suggest to split this it two scripts, one rc script, that
only provides non-destructive operations like
(start|stop|restart|rcvar) and one called vm-admin which provides the
provisions functions on top, e.g.

service vm start vm0 # ok
vm-admin start vm0 # ok
service vm format vm0 ... # not ok
vm-admin format vm0 ... # ok

Michael Gmelin

More information about the freebsd-virtualization mailing list