SR-IOV pool with static MAC address and vlan

Yalan Zhang yalzhang at redhat.com
Mon Apr 3 13:17:45 UTC 2023


Hi Paul,

You can set the static MAC address and VLAN in the interface section of the
VM xml.
So it will not change even when the VM shuts down and restarts.
VM interface xml:
<interface type='network'>
<mac address='52:54:00:85:e2:cd'/>
<source network='hostdev_net'/>
      <vlan>
        <tag id='42'/>
      </vlan>
    </interface>

And set the network(vf pool) with xml like below:
# cat hostnet.xml
<network>
 <name>hostdev_net</name>
  <forward mode='hostdev' managed='yes'>
    <pf dev='eth0'/>
  </forward>
</network>
(eth0 is the PF's name, refer to
https://libvirt.org/formatnetwork.html#connectivity, hostdev part)
or:
# cat hostnet.xml
<network>
 <name>hostdev_net</name>
  <forward mode='hostdev' managed='yes'>
   <address type='pci' domain='0x0000' bus='0x03' slot='0x10'
function='0x0'/>
  <address type='pci' domain='0x0000' bus='0x03' slot='0x10'
function='0x2'/>
  </forward>
</network>
(the address is VF's pci address, you can specify multiple addresses at
once)

# virsh net-define hostnet.xml
# virsh net-start hostdev_net

Hope it helps.

BR
Yalan


On Sun, Apr 2, 2023 at 10:06 AM Paul B. Henson <henson at acm.org> wrote:

> I'm planning to set up a libvirt/kvm system using a card with SR-IOV
> support. I'd like to use the vf pool option rather than statically
> assigning a vf to each vm. However, I'd also like each vm to have a
> static MAC address and I have multiple VLANs they will be on.
>
> I found in the documentation a syntax for specifying a MAC and a vlan
> when the vf is statically assigned, but I don't see anything in the
> documentation about doing so when using a vf pool?
>
> Did I miss something? Is it possible to do so? If not, is there some
> other way to handle MAC addresses and vlans with a vf pool, or if you
> need those are you stuck with static assignment?
>
> Thanks much...
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20230403/da5f4649/attachment.htm>


More information about the libvirt-users mailing list