After importing a virtual machine exported from VirtualBox into libvirt, the network interface shows up as ens3
. Would it be possible to adapt the domain configuration to make it instead appear as enp0s3
like it did in VirtualBox?
At first one might think that it was the reboot, not the migration, which caused systemd to enumerate the interface differently. However, since the interface in source environment still remains enp0s3
after reboot, that is verified to not be the case
While it is trivial to update network configuration inside the virtual machine, it would be preferable to solve it outside of the vm. There are more than one to migrate, and they are of many different flavors.
My host with the target libvirt (7.0.0-3) is running Debian bullseye and KVM is the hypervisor used.
This answer suggests the p0
part is decided by the bus number. The top comment in this source code for systemd authoritatively shouts a link to predictable interface names, which claims the goal is stable naming even after hardware changes. I stopped myself short of diving into the details of trying to understand how it all is actually implemented. I find the description of whether to include p0
or not, quoted below, to be in insufficient detail for me to understand:
- Names incorporating Firmware/BIOS provided PCI Express hotplug slot index numbers (example: ens1)
- Names incorporating physical/geographical location of the connector of the hardware (example: enp2s0)
…falling back to 3) if applicable…
What makes it applicable? I understand all the words, but fail to understand where to search. So instead, over to the fun part of attempting to accomplish while lacking full understanding. If editing the bus number in raw XML definition of the network interface the interface name does become enp1s3
.
--- ens3 2022-05-28 00:00:00 +0000
+++ enp1s3 2022-05-28 01:00:00 +0000
@@ -100,3 + 100,3 @@
<alias name='net0'/>
- <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ <address type='pci' domain='0x0000' bus='0x01' slot='0x03' function='0x0'/>
</interface>
What is causing systemd to select policy 3 when running under VirtualBox, but policy 2 when in the libvirt environment? Can libvirt be configured to make systemd include the bus number even when it is zero?
I've attempted all options imaginable to me. Including adding another interface, but that only ended up in a state of mixed naming (with policy 2 used for ens3
and policy 3 for enp1s3
, which rhymes well with naming being stable). Did also try selecting every available type of network card, but no success.