<div dir="ltr"><p>Hi everyone,<br>
  <br>
We have an issue with how network interfaces are presented in the VM with the latest libvirt 7.4.0 and qemu 6.0.0. <br>
  
  <br>
Previously, we were on libvirt 7.0.0 and qemu 5.2.0, and we used 
increasing virtual PCI addresses for any type of network interface 
(virtio, PCI passthrough, SRIOV) in order to decide the interface order 
inside the VM. For instance the following snippet yields ens1, ens2 and 
ens3 in a Debian Buster VM:<br>
  <br>
  <interface type="ethernet"><br>
     <target dev="0.vSrv"/><br>
     <mac address="52:54:00:aa:cc:05"/><br>
     <address bus="0x01" domain="0x0000" function="0x0" slot="0x01" type="pci"/><br>
     <model type="virtio"/><br>
     <driver><br>
        <host csum="off"/><br>
     </driver><br>
  </interface><br>
  <interface type="ethernet"><br>
     <target dev="1.vSrv"/><br>
     <mac address="52:54:00:aa:bb:81"/><br>
     <address bus="0x01" domain="0x0000" function="0x0" slot="0x02" type="pci"/><br>
     <model type="virtio"/><br>
     <driver><br>
        <host csum="off"/><br>
     </driver><br>
  </interface><br>
  <hostdev managed="yes" mode="subsystem" type="pci"><br>
     <source><br>
        <address bus="0x0d" domain="0x0000" function="0x0" slot="0x00"/><br>
     </source><br>
     <address bus="0x01" domain="0x0000" function="0x0" slot="0x03" type="pci"/><br>
  </hostdev><br>
  <br>
After upgrading to libvirt 7.4.0 and qemu 6.0.0, the XML snippet above yielded:<br>
- ens1 for the first virtio interface => OK<br>
- rename4 for the second virtio interface => **KO**<br>
- ens3 for the PCI passthrough interface  => OK<br>
  <br>
Argh! What happened to ens2? By running udev inside the VM, I see that "rename4" is the 
result of a conflict between the ID_NET_NAME_SLOT of the second and the 
third interface, both appearing as ID_NET_NAME_SLOT=ens3. In theory 
rename4 should show ID_NET_NAME_SLOT=ens2. What happened?<br>
  <br>
#  udevadm info -q all /sys/class/net/rename4<br>
P: /devices/pci0000:00/0000:00:03.0/0000:01:02.0/virtio4/net/rename4<br>
L: 0<br>
E: DEVPATH=/devices/pci0000:00/0000:00:03.0/0000:01:02.0/virtio4/net/rename4<br>
E: INTERFACE=rename4<br>
E: IFINDEX=4<br>
E: SUBSYSTEM=net<br>
E: USEC_INITIALIZED=94191911<br>
E: ID_NET_NAMING_SCHEME=v240<br>
E: ID_NET_NAME_MAC=enx525400aabba1<br>
E: ID_NET_NAME_PATH=enp1s2<br>
E: ID_NET_NAME_SLOT=ens3<br>
E: ID_BUS=pci<br>
E: ID_VENDOR_ID=0x1af4<br>
E: ID_MODEL_ID=0x1000<br>
E: ID_PCI_CLASS_FROM_DATABASE=Network controller<br>
E: ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller<br>
E: ID_VENDOR_FROM_DATABASE=Red Hat, Inc.<br>
E: ID_MODEL_FROM_DATABASE=Virtio network device<br>
E: ID_PATH=pci-0000:01:02.0<br>
E: ID_PATH_TAG=pci-0000_01_02_0<br>
E: ID_NET_DRIVER=virtio_net<br>
E: ID_NET_LINK_FILE=/usr/lib/systemd/network/99-default.link<br>
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/rename4<br>
E: TAGS=:systemd:<br>
  <br>
#  udevadm info -q all /sys/class/net/ens3<br>
P: /devices/pci0000:00/0000:00:03.0/0000:01:03.0/net/ens3<br>
L: 0<br>
E: DEVPATH=/devices/pci0000:00/0000:00:03.0/0000:01:03.0/net/ens3<br>
E: INTERFACE=ens3<br>
E: IFINDEX=2<br>
E: SUBSYSTEM=net<br>
E: USEC_INITIALIZED=3600940<br>
E: ID_NET_NAMING_SCHEME=v240<br>
E: ID_NET_NAME_MAC=enx00900b621235<br>
E: ID_OUI_FROM_DATABASE=LANNER ELECTRONICS, INC.<br>
E: ID_NET_NAME_PATH=enp1s3<br>
E: ID_NET_NAME_SLOT=ens3<br>
E: ID_BUS=pci<br>
E: ID_VENDOR_ID=0x8086<br>
E: ID_MODEL_ID=0x1533<br>
E: ID_PCI_CLASS_FROM_DATABASE=Network controller<br>
E: ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller<br>
E: ID_VENDOR_FROM_DATABASE=Intel Corporation<br>
E: ID_MODEL_FROM_DATABASE=I210 Gigabit Network Connection<br>
E: ID_PATH=pci-0000:01:03.0<br>
E: ID_PATH_TAG=pci-0000_01_03_0<br>
E: ID_NET_DRIVER=igb<br>
E: ID_NET_LINK_FILE=/usr/lib/systemd/network/99-default.link<br>
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/ens3<br>
E: TAGS=:systemd:<br>
  <br>
  <br>
Is there anything we can do in the XML definition of the VM to fix this?<br>
  <br>
The PCI tree from within the VM is the following, if it helps:<br>
(with libvirt 7.0.0 and qemu 5.2.0 it was the same)<br>
  <br>
# lspci -tv<br>
-[0000:00]-+-00.0  Intel Corporation 440FX - 82441FX PMC [Natoma]<br>
           +-01.0  Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]<br>
           +-01.1  Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]<br>
           +-01.2  Intel Corporation 82371SB PIIX3 USB [Natoma/Triton II]<br>
           +-01.3  Intel Corporation 82371AB/EB/MB PIIX4 ACPI<br>
           +-02.0  Cirrus Logic GD 5446<br>
           +-03.0-[01]--+-01.0  Red Hat, Inc. Virtio network device<br>
           |            +-02.0  Red Hat, Inc. Virtio network device<br>
           |            \-03.0  Intel Corporation I210 Gigabit Network Connection<br>
           +-04.0-[02]--<br>
           +-05.0-[03]--<br>
           +-06.0-[04]--<br>
           +-07.0-[05]--<br>
           +-08.0-[06]----01.0  Red Hat, Inc. Virtio block device<br>
           +-09.0  Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 6 port SATA Controller [AHCI mode]<br>
           +-0a.0  Red Hat, Inc. Virtio console<br>
           +-0b.0  Red Hat, Inc. Virtio memory balloon<br>
           \-0c.0  Red Hat, Inc. Virtio RNG<br>
           <br>
  
  <br>
I see that a new feature in qemu and libvirt is to add ACPI indices in 
order to have network interfaces appear as *onboard* and sort them 
through this index as opposed to virtual PCI addresses. This is great. I
 see that in this case, interfaces appear as eno1, eno2, etc.<br>
  <br>
However, for the sake of backward compatibility, is there a way to have 
the previous behaviour where interfaces were called by their PCI slot 
number (ens1, ens2, etc.)?<br>
  <br>
If I move to the new naming yielded by ACPI indices, I am mostly worried
 about any possible change in interface names that might occur across 
VMs running different OS's, with respect to what we had before with 
libvirt 7.0.0 and qemu 5.2.0.<br>
  <br>
Thanks!<br>
  <br>
Best,<br>
Riccardo Ravaioli</p>
</div>