# Is libvirt Bhyve PCI passthru possible on FreeBSD



## Phishfry (Mar 9, 2020)

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.








						Chapter 15. PCI passthrough Red Hat Enterprise Linux 5 | Red Hat Customer Portal
					

Access Red Hat’s knowledge, guidance, and support through your subscription.




					access.redhat.com
				



`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.


----------



## Phishfry (Mar 9, 2020)

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.


----------



## Phishfry (Mar 9, 2020)

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.








						Allow PCI functions up to 255 for PCI ARI (1424eedd) · Commits · Ryan Moeller / libvirt · GitLab
					

PCI Alternative Routing-ID Interpretation (ARI) capable devices use an implied Device Number of 0 and repurpose those bits to allow for 256 Function Numbers instead of 8. An example of...




					gitlab.com


----------



## Phishfry (Mar 12, 2020)

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.


----------



## shkhln (Mar 12, 2020)

Phishfry said:


> I am guessing I passthru the slots? Like this:
> -s 6/0/0,passthru



Try it.


----------



## shkhln (Mar 12, 2020)

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.)


----------



## Phishfry (Mar 12, 2020)

The hostdev type passthru is what Ryan recently added to libvirt for FreeBSD. Not yet commited to libvirt.


			https://gitlab.com/freqlabs/libvirt/-/commit/2267c85f81b5d60653b279505b6df1aa58329f4b


----------



## shkhln (Mar 12, 2020)

Ah, ok. That makes sense.


----------

