
Greetings, I wanted to know if it is possible to attach a virtual nic (shows up as 02:01.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8100/8101L/8139 PCI Fast Ethernet Adapter (rev 20)) to the vfio module, when I modprobe it I get this error: [ 854.624668] vfio-pci: probe of 0000:02:01.0 failed with error -22 Thanks, Dagg

On 6/12/24 20:24, daggs via Users wrote:
Greetings,
I wanted to know if it is possible to attach a virtual nic (shows up as 02:01.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8100/8101L/8139 PCI Fast Ethernet Adapter (rev 20)) to the vfio module, when I modprobe it I get this error: [ 854.624668] vfio-pci: probe of 0000:02:01.0 failed with error -22
No, you need to declare the vNIC with model 'virtio': <interface type='network'> <mac address='52:54:00:XX:XX:XX'/> <source network='default'/> <model type='virtio'/> </interface> Virtio is an interface that allows more effective data transfer between host and guest [1][2]. It's a paravirtualized device. In other words, if you started a guest and told hypervisor to emulate RTL8139 NIC then it'll do just that. 1: https://wiki.osdev.org/Virtio 2: https://wiki.libvirt.org/Virtio.html Michal

Greetings Michal, I think I might be doing something wrong, all the devices are defined a such: <interface type='network'> <mac address='52:54:xx:xx:xx:xx'/> <source network='mynet'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x10' slot='0x0x' function='0x0'/> </interface> and I still cannot get vfio to attached to them. they are autobinded to virtio_pci so I had to unbind them first when I reload the vfio module, I get the same errors below I'm trying to attach it inside a running guest, in short, I want to be able to pass a vNIC to a nested guest for development reasons Thanks, Dagg
Sent: Thursday, June 13, 2024 at 5:45 PM From: "Michal Prívozník" <mprivozn@redhat.com> To: "daggs" <daggs@gmx.com>, users@lists.libvirt.org Subject: Re: vfio usage in a vm
On 6/12/24 20:24, daggs via Users wrote:
Greetings,
I wanted to know if it is possible to attach a virtual nic (shows up as 02:01.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8100/8101L/8139 PCI Fast Ethernet Adapter (rev 20)) to the vfio module, when I modprobe it I get this error: [ 854.624668] vfio-pci: probe of 0000:02:01.0 failed with error -22
No, you need to declare the vNIC with model 'virtio':
<interface type='network'> <mac address='52:54:00:XX:XX:XX'/> <source network='default'/> <model type='virtio'/> </interface>
Virtio is an interface that allows more effective data transfer between host and guest [1][2]. It's a paravirtualized device. In other words, if you started a guest and told hypervisor to emulate RTL8139 NIC then it'll do just that.
1: https://wiki.osdev.org/Virtio 2: https://wiki.libvirt.org/Virtio.html
Michal

On 6/13/24 18:18, daggs wrote:
Greetings Michal,
I think I might be doing something wrong, all the devices are defined a such: <interface type='network'> <mac address='52:54:xx:xx:xx:xx'/> <source network='mynet'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x10' slot='0x0x' function='0x0'/> </interface>
and I still cannot get vfio to attached to them. they are autobinded to virtio_pci so I had to unbind them first when I reload the vfio module, I get the same errors below
Ah, so I've misunderstood what you meant. Virtio and VFIO are two different approaches. While the former is for emulated devices, the latter is for PCI assignment (aka "PCI passthrough"). Your L1 guest is correctly binding the vNIC to virtio.
I'm trying to attach it inside a running guest, in short, I want to be able to pass a vNIC to a nested guest for development reasons
This could be possible, but you'll need to give your L1 guest vIOMMU: <iommu model='intel'> <driver intremap='on'/> </iommu> https://libvirt.org/formatdomain.html#iommu-devices Then, to assign this L1 virtio vNIC to the L2 guest you can either do <hostdev/> or <interface type='hostdev'/>: https://libvirt.org/formatdomain.html#pci-passthrough Michal

Sent: Friday, June 14, 2024 at 9:33 AM From: "Michal Prívozník" <mprivozn@redhat.com> To: "daggs" <daggs@gmx.com> Cc: users@lists.libvirt.org Subject: Re: vfio usage in a vm
On 6/13/24 18:18, daggs wrote:
Greetings Michal,
I think I might be doing something wrong, all the devices are defined a such: <interface type='network'> <mac address='52:54:xx:xx:xx:xx'/> <source network='mynet'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x10' slot='0x0x' function='0x0'/> </interface>
and I still cannot get vfio to attached to them. they are autobinded to virtio_pci so I had to unbind them first when I reload the vfio module, I get the same errors below
Ah, so I've misunderstood what you meant. Virtio and VFIO are two different approaches. While the former is for emulated devices, the latter is for PCI assignment (aka "PCI passthrough"). Your L1 guest is correctly binding the vNIC to virtio.
I'm trying to attach it inside a running guest, in short, I want to be able to pass a vNIC to a nested guest for development reasons
This could be possible, but you'll need to give your L1 guest vIOMMU:
<iommu model='intel'> <driver intremap='on'/> </iommu>
https://libvirt.org/formatdomain.html#iommu-devices
Then, to assign this L1 virtio vNIC to the L2 guest you can either do <hostdev/> or <interface type='hostdev'/>:
thanks, after enabling the iommu in the guest, vfio-pci is attached to the nics. thanks for all the help Dagg
participants (2)
-
daggs
-
Michal Prívozník