]> xenbits.xensource.com Git - osstest.git/commitdiff
preseed_base, ts-host-install: Change NIC NamePolicy to "mac"
authorAnthony PERARD <anthony.perard@citrix.com>
Wed, 25 Oct 2023 16:18:31 +0000 (17:18 +0100)
committerAnthony PERARD <anthony.perard@citrix.com>
Thu, 28 Mar 2024 16:51:52 +0000 (16:51 +0000)
On "italia?" machine, the two network interfaces are competing to have
"eno1", base on the "onboard" naming policy. So the name of the
network interface can change between "eno1" and "eth0".

Switching to "mac" should avoid the unpredictable name based on
"onboard" or "slot" policy.

The "mac" naming policy break `vif-bridge` for the "vif*.*" network
interfaces. So we will avoid the "mac" policy if the driver is "vif".
This also have an impact on guest created with ./ts-debian-install, as
they use the initrd from dom0, so the interface in the guest will be
renamed according to default policy (which rename eth0 to enX0).

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Osstest/Debian.pm
ts-host-install

index 102b02464bce0f289e87ab3a5e94078073e92162..31d32d6fca9b84b4a46d5af4750371b8a77ce4c2 100644 (file)
@@ -962,6 +962,28 @@ cp /$RULESDIR/70-persistent-*.rules /target/$RULESDIR 2>/dev/null || true
 
 END
 
+    if ($ho->{Suite} !~ m/lenny|squeeze|wheezy|jessie|stretch|buster/) {
+        # Always use MAC address in network interface names.
+        #
+        # But keep the default policy if the driver is "vif", which match the
+        # "vif$domid.$idx" interface in dom0, and the interface in domU. This file
+        # is going to be added to dom0's initrd, which is used by some guests
+        # (created with ts-debian-install).
+        preseed_hook_installscript($ho, $sfx,
+            '/usr/lib/base-installer.d/', '05ifnamepolicy', <<'END');
+#!/bin/sh -e
+linkfile=/target/etc/systemd/network/90-eth-mac-policy.link
+mkdir -p `dirname $linkfile`
+cat > $linkfile <<EOF
+[Match]
+Type=ether
+Driver=!vif
+[Link]
+NamePolicy=mac
+EOF
+END
+    }
+
     debian_overlays($ho, sub {
        my ($srcdir, $tfilename) = @_;
        preseed_hook_overlay($ho, $sfx, $srcdir, $tfilename);
index 8848103807ac01fb276211384327122bd61392f7..0b6aaeeae228551064618abfa624321992a2eb2d 100755 (executable)
@@ -248,6 +248,22 @@ END
     print CANARY "\n# - canary - came via initramfs\n" or die $!;
     close CANARY or die $!;
 
+    if ($ho->{Suite} !~ m/lenny|squeeze|wheezy|jessie|stretch|buster/) {
+        # Switch to more predictale nic name based on mac address, instead of the
+        # policy "onboard" which can try to set the same name ("eno1") to two
+        # differents nic, or "slot". New names are "enx$mac".
+        system_checked(qw(mkdir -p --), "$initrd_overlay.d/lib/systemd/network");
+        file_simple_write_contents
+            ("$initrd_overlay.d/lib/systemd/network/90-eth-mac-policy.link",
+                <<END);
+[Match]
+Type=ether
+Driver=!vif
+[Link]
+NamePolicy=mac
+END
+    }
+
     my %xopts;
 
     di_special_kernel($ho, sub {