cirrax / puppet-libvirt

puppet module for libvirt
GNU General Public License v3.0
8 stars 25 forks source link

SR-IOV hostdev network fails #52

Closed sazzle2611 closed 1 year ago

sazzle2611 commented 3 years ago

Hi,

We installed this module a few years ago and it's been working perfectly. I have just upgraded it and realised that I had to edit a couple of things originally to make it work for us, this was v3.0.0, but as I wanted the latest module I copied the old to another place and ran the upgrade to v4.3.2 with the option --ignore-changes

I then came across the same errors I had before, sorry should have submitted a ticket then. So our setup uses SR-IOV network interfaces with hostdev

The error was

Notice: /Stage[main]/Libvirt/Libvirt::Network[sr-iov-net-1]/Exec[libvirt-network-sr-iov-net-1]/returns: error: unsupported configuration: hostdev network 'sr-iov-net-1' lists 'enp3s0f0' in the device pool, but hostdev networks require all devices to be listed by PCI address, not network device name

The changes that I needed to make to your module were in templates/network.xml.erb

Line 4

<forward<%-if @forward_dev -%> dev='<%= @forward_dev -%>'<%-end-%> mode='<%= @forward_mode -%>'<%-if @forward_interfaces.empty? -%>/<%-end-%> managed='yes'>

and Line 7

<pf dev='<%= dev -%>'/>

and this is the hiera config that caused the issue

libvirt::create_networks:
  sr-iov-net-1:
    forward_mode: 'hostdev'
    forward_interfaces:
      - 'enp3s0f0'
  sr-iov-net-2:
    forward_mode: 'hostdev'
    forward_interfaces:
      - 'enp3s0f1'

It's not a big issue for us as we have fixed it but we will obviously come up against it every time we upgrade so would really appreciate it if it can be looked at at some point. Either that or tell us a better config that works ;)

We are in the process of installing a couple of new servers so if you want us to test anything in the next couple of days then we are more than happy to but after that they will probably be in production so wont be possible.

Thanks, Sarah

trefzer commented 3 years ago

Hi Sarah Well it's always a good idea to fix bugs upstream, thats opensource !! Can you show me the resulting network xml with youre fix ?

sazzle2611 commented 3 years ago

Hi @trefzer Not totally sure what you mean, do you just mean the xml generated by the template after the changes I made?

<network>
  <name>sr-iov-net-1</name>
  <forward mode="hostdev" managed='yes'>
    <pf dev='enp3s0f0' />
  </forward>
</network>
sazzle2611 commented 3 years ago

Just for info I have now changed line 4 to this as we got a server that doesn't use SR-IOV VF's so needed it to work with bridge as well

<forward<%-if @forward_dev -%> dev='<%= @forward_dev -%>'<%-end-%> mode='<%= @forward_mode -%>'<%-if @forward_interfaces.empty? -%>/<%-end-%> <%-if @forward_mode == 'hostdev' -%>managed='yes'<%-end-%>>

The change in the whole line is adding

<%-if @forward_mode == 'hostdev' -%>managed='yes'<%-end-%>

Thanks

trefzer commented 1 year ago

I will not fix this in the 'old' template used until now. If you switch to version 5.0.0 (currently in preview #64) you can use the new generic template, which is more flexible and lets you define:

libvirt::create_networks:
  sr-iov-net-1:
    template: 'generic'
    forward:
        managed: 'yes'
        mode: 'hostdev'
        pf:
          dev: 'enp3s0f0'

Which generates the xml shown above (the sorting of elements/attributes is different since we do not use execs anymore which needs 'normalize' (=sort) the generated XML's).