VM Template: Add UI option for configuring multifunction='on' for PCIe passthrough devices


Recommended Posts

I tried looking for existing posts about this but couldn't find any, so hopefully this isn't a duplicate

 

It would be really helpful to be able to set the `multifunction='on'` for certain passthrough devices, such as a NIC for pfSense.

 

Use Case: In order to get my pfSense VM to recognize the NIC ports as 4 separate interfaces (rather seeing than the whole card as only one interface), I have to manually edit the xml to set the 4 "devices" that make up the NIC so that the first has multifunction='on' and the others have the correct matching bus and function address values. 

However, the problem really is that if I forget and make any edit via the VM template in the webUI, then it will "undo" this multifunction option.

 

Since this "multifunction" thing is actually (usually) a capability of the device, it should be possible for Unraid to detect when it should provide this option by looking for the fact that the addresses of the devices are all in the form 

04:00.0
04:00.1
04:00.2
04:00.3
etc...

 

As an alternative or additional method of detection, you may also notice that they should all have the same device ids,

For example mine shows 8086:1521 on all 4 of these because they are the 4 interfaces of same physically PCIe card:

IOMMU group 20:	[8086:1521] 04:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
IOMMU group 21:	[8086:1521] 04:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
IOMMU group 22:	[8086:1521] 04:00.2 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
IOMMU group 23:	[8086:1521] 04:00.3 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)

 

 

Of course, I understand that just because this looks simple in theory, that doesn't mean it will be easy to implement in practice. I don't fully know how the UI--XML generation works, but I have been involved in software development long enough to know that there may be other obstacles or limitations of the system that I am completely unaware of. So, I completely understand if this request/idea gets rejected.

 

 

Lastly, I would like to provide an example of the "desired" XML with multifunction enabled vs. the default XML generated by the VM Template

 

Here is the XML with multifunction enabled:

...
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
      </source>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0' multifunction='on'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x04' slot='0x00' function='0x1'/>
      </source>
      <alias name='hostdev1'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x04' slot='0x00' function='0x2'/>
      </source>
      <alias name='hostdev2'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x2'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x04' slot='0x00' function='0x3'/>
      </source>
      <alias name='hostdev3'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x3'/>
    </hostdev>
...

 

 

Here is the XML generated by the webUI:

...
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
      </source>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x04' slot='0x00' function='0x1'/>
      </source>
      <alias name='hostdev1'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x04' slot='0x00' function='0x2'/>
      </source>
      <alias name='hostdev2'/>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x04' slot='0x00' function='0x3'/>
      </source>
      <alias name='hostdev3'/>
      <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
    </hostdev>
...

 

  • Upvote 1
Link to comment
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.