I'm trying out different ways of launching my bhyve(8) VMs. I'm familiar with the various bhyve management packages that are available and have used some before with success, but I slightly dislike some of the abstraction they do, so I'm rolling my own way of doing it.
I've created shell scripts which run bhyve with all the command line arguments necessary to set up the required virtual hardware configuration and this has worked fine, but now I'm looking at a cleaner method of using a configuration file as described by bhyve_config(5) and simply launching
In the config file, I'm specifying network interfaces to create with:
As I'm using
I could parse the output of
Another option is using
Can anyone suggest any other nice and clean ways of gleaning this information?
I've created shell scripts which run bhyve with all the command line arguments necessary to set up the required virtual hardware configuration and this has worked fine, but now I'm looking at a cleaner method of using a configuration file as described by bhyve_config(5) and simply launching
bhyve -k config_file from my script.In the config file, I'm specifying network interfaces to create with:
Code:
pci.0.2.0.device=virtio-net
pci.0.2.0.backend=tap
pci.0.2.1.device=virtio-net
pci.0.2.1.backend=tap
pci.0.2.2.device=virtio-net
pci.0.2.2.backend=tap
pci.0.2.3.device=virtio-net
pci.0.2.3.backend=tap
As I'm using
pci.x.y.z.backend=tap with no tap instance number specified, the interfaces are automatically created using the first available instance numbers, but then I need some way of programmatically determining which numbers it used, so that the script can then add them to bridges as appropriate, and later destroy them when the VM is terminated.I could parse the output of
ifconfig -a -g tap to look for tap interfaces that include an "Opened by PID n" line, where 'n' matches the bhyve PID, but this strikes me as a bit clunky and inelegant.Another option is using
procstat files PID | grep '/dev/tap' which would be slightly easier to parse.Can anyone suggest any other nice and clean ways of gleaning this information?