Is libvirt Bhyve PCI passthru possible on FreeBSD

I want to passthru a NIC to my libvirt Bhyve VM and since libvirt is primarily a Linux tool I am coming up short on instructions.
Here the recommend hostdev type device:
https://libvirt.org/formatdomain.html#elementsNICSHostdev
This don't work as we do not have VFIO on FreeBSD:

This does not work either.
virsh nodedev-list --tree
error: Failed to count node devices
error: this function is not supported by the connection driver: virNodeNumOfDevices


I wonder if anyone has tried to passthru devices to bhyve via libvirt XML file.
I am using libvirt bhyve on FreeBSD passing thru to FreeBSD VM.
 
I also tried with the device type 'direct'
<devices>
<interface type='direct' trustGuestRxFilters='yes'>
<source dev='em0'/>
<mac address='00:1b:21:2c:31:e5 '/>
<boot order='1'/>
<rom bar='off'/>
</interface>
</devices>

This didn't work either. I am unsure if I need to use a PPT device or raw.
 
I noticed Ryan_Moeller has a commit in for more PCI passthru devices with libvirt so I know passthru is possible.
I might need to switch to a different ethernet device as I am using a Quad Port Gigabit Intel card and this commit is for VF's found on 10G ethernet cards.
 
Ryan was nice enough to email me back. He noted that the PCI Passthru can be used this way:
libvirt: Bhyve driver
The relevant line:
<bhyve:arg value='-somebhyvearg'/>

Can anyone help me figure that out?
My bhyve command line is very long so I am unsure what to use here.
bhyve -S -c 8 -m 8G -AHP -u -s 0:0,hostbridge -s 1:0,lpc -s 2:0,ahci-hd,/vm/freebsd/freebsd1.img -s 7:0,passthru,6/0/0 -s 30:0,xhci,tablet -l com1,stdio -l bootrom,/vm/freebsd/BHYVE_UEFI.fd freebsd1'
I am guessing I passthru the slots? This is my network card passthru:
-s 7:0,passthru,6/0/0
I am lost here.
I feel like an idiot if I send another mail to show me an example. But I might....
Almost feel like offering him some coin to hand walk me through it.
I posted this here to save Ryan some time just incase anyone knows here.
 
On a more general note, the intended way of libvirt PCI passthrough configuration is described here and it looks like these elements are currently unsupported by the bhyve driver. (Disclaimer: I never used any of this.)
 
It works at present by adding your passthru command via $your_vm_name.xml section like this:
Code:
<domain type="bhyve" xmlns:bhyve="http://libvirt.org/schemas/domain/bhyve/1.0">
  ...
  <bhyve:commandline>
    <bhyve:arg value='-s 8,passthru,6/0/0'/>
    <bhyve:arg value='-s 9,passthru,8/0/0'/>
 .... (whatever other -s command you want to pass)
  </bhyve:commandline>
</domain>
As described here. Then virsh edit command will guide toward the correct syntax.
NB: just don't forget to add the URI and the <domain> header.
 
Back
Top