bhyve C API for Bhyve management?

Hey!

I am new to FreeBSD and was captivated by its elegance pretty much from the first moment on.

Given its excellent hypervisor performance (I am talking about Bhyve of course), I am tempted to write a **lightweight** VM orchestrator for things such as code compilation on different platforms, automated tests, etc. This mainly consists of creating new VMs, running them, and sending a few console commands. The bhyve CLI tools seem amazing and intuitive, but of course for automation one would prefer to not parse plaintext. I was wondering if there is a way from e.g. C to run bhyve commands without posix_spawn() "hackery". I know libvmmapi exists, but that is way too low-level for my purposes. So what is the usual way of writing such an automation/"orchestrator"? Is it truly by parsing plaintext returned by spawning CLIs? Or am I missing something? Would there be demand for someone (possibly me?) refactoring bhyve into a library foremost and rewriting the CLI to use that library (looking at the source, this task is not too daunting due to the high quality modularization of the code)? Or is my thinking far off from that of a UNIX user?

Thanks and Cheers!
 
I have seen libvirt beforehand, and as useful as it is on Linux, I don't see it as useful on FreeBSD.

First of all, libvirt - even though it has (now mature-ish) drivers for Bhyve - mainly focuses on Qemu support. That is their primary target, and I am afraid its existence on BSD today is foremost due to the hard work of hardcore BSD fans.

As far as I understand, libvirt is an API on top of the virtualization on the given platform. The problem with this is, as always, that this means we are trying to unify inherently incompatable platforms under some magic interface. The first pain point with libvirt appears the moment you create a new VM. Every VM state is internally stored and managed by libvirt. Now this defeats the purpose of bhyve tools (that are so convinient. I do not want to rewrite them all for my orchestrator, I just want to start new VMs).

As such, to keep coherency, it seems logical to expose Bhyve specific APIs that keep these tools useful. That is why I don't seriously consider libvirt as a solution to my problem.
 
Back
Top