SR-IOV Network, random MAC addr?

Been fighting on and off with SR-IOV networking on my Fedora 31 Threadripper server all day.

I have a few VF nics present, and have assigned them to various virtual machines. The Windows guests are fat and happy.

The Linux guests not so much. Their network configs don’t stick, even when done manually.

The problem seems to be, they get a random MAC address every time the guest machine boots.

Any suggestions how to lock down the MAC address for these virtual cards?

Here is the xml segment from where I have the VF assigned to a Centos 7 guest, this was generated using the virt-manager gui

    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x08' slot='0x10' function='0x2'/>
      </source>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </hostdev>

Both Redhat and Fedora docs indicate there’s a <mac address=> tag that can be used, but I get an error when I add that to the xml

error: (domain_definition):136: Opening and ending tag mismatch: mac line 134 and hostdev
    </hostdev>

I also followed the full example in the Centos 7 docs (Fedora 31 doesn’t seem to have any virtualization docs)

<interface type='hostdev' managed='yes'>
  <source>
    <address type='pci' domain='0' bus='8' slot='10' function='2'/>
  </source>
  <mac address='52:54:00:6d:90:02'>
</interface>
# EDITOR=nano virsh edit centos-docker
error: (domain_definition):148: Opening and ending tag mismatch: mac line 147 and interface
    </interface>
----------------^

Any ideas?

1 Like

missing a few lines apparently, found the complete docs on the kvm website

Here’s what it wants

    <interface type='hostdev' managed='yes'>
      <mac address='52:54:00:6d:90:02'/>
      <driver name='vfio'/>
      <source>
        <address type='pci' domain='0x0000' bus='0x08' slot='0x10' function='0x2'/>
      </source>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>
2 Likes