All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Roger Pau Monne <roger.pau@citrix.com>
Subject: [OSSTEST PATCH 14/36] preseed_base, ts-host-install: Change NIC NamePolicy to "mac"
Date: Mon, 18 Mar 2024 16:55:23 +0000	[thread overview]
Message-ID: <20240318165545.3898-15-anthony.perard@citrix.com> (raw)
In-Reply-To: <20240318165545.3898-1-anthony.perard@citrix.com>

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>
---
 Osstest/Debian.pm | 22 ++++++++++++++++++++++
 ts-host-install   | 16 ++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm
index 102b0246..31d32d6f 100644
--- a/Osstest/Debian.pm
+++ b/Osstest/Debian.pm
@@ -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);
diff --git a/ts-host-install b/ts-host-install
index 88481038..0b6aaeea 100755
--- a/ts-host-install
+++ b/ts-host-install
@@ -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 {
-- 
Anthony PERARD



  parent reply	other threads:[~2024-03-18 16:56 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18 16:55 [OSSTEST PATCH 00/36] Switch to Debian Bookworm Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 01/36] production-config: Add bookworm debian install media filename Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 02/36] ts-xen-build-prep: Only force git protocol v2 on buster Anthony PERARD
2024-03-20 15:20   ` Roger Pau Monné
2024-03-20 16:34     ` Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 03/36] mgi-common: Fix fetch_debian_package error message Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 04/36] mg-debian-installer-update: Download non-free firmware from new repo Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 05/36] ts-host-install: fix ntp.conf path on bookworm Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 06/36] ts-host-install: fix ntp server setting Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 07/36] ts-host-install: Restart ntp service Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 08/36] preseed_create: Use new "d-i grub-installer/update-nvram" for UEFI installation Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 09/36] preseed_create: osstest-erase-other-disks: workaround creating /dev/sdXD files Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 10/36] preseed_create: Workaround fail grub-install on arndale Anthony PERARD
2024-03-20 16:38   ` Roger Pau Monné
2024-03-26 12:28     ` Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 11/36] ts-host-install,preseed_create: Do lvm vgextend at install time Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 12/36] di_installcmdline_core: Add link_wait_timeout to install cmdline Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 13/36] Disable persistent net generator on Bookworm Anthony PERARD
2024-03-18 16:55 ` Anthony PERARD [this message]
2024-03-18 16:55 ` [OSSTEST PATCH 15/36] ts-xen-build-prep: Change package selection for Bookworm Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 16/36] bl_getmenu_open: Read grub.cfg as root Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 17/36] target_editfile: Use the same user to retrieve and send Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 18/36] ts-xen-install: remove "libc6-xen" package installation Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 19/36] overlay-bookworm: Import grub's 20_linux_xen from Debian Bookworm Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 20/36] overlay-bookworm: 20_linux_xen: Fix XSM entries generation Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 21/36] ts-xtf-install: Install python symlink Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 22/36] setupboot_grub2: Parse arm64 uefi grub verbes Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 23/36] bookworm: Extend ARM clock workaround Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 24/36] ts-nested-setup, setup l1 lvm volume groupe in guest Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 25/36] ts-leak-check: add new name for udevd workers Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 26/36] ts-debian-hvm-install: Allow udev failure in install media Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 27/36] ts-debian-fixup: Fix nic names for bookworm Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 28/36] ts-debian-install: keep avoiding to use pygrub Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 29/36] ts-debian-hvm-install: Increase min guest ram size Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 30/36] bookworm: Extend guest bootloader workaround Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 31/36] ts-debian-*-install: Replace dots in hostnames by dashs Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 32/36] ts-xen-install: Fix bridge setup, ask to copy MAC addr Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 33/36] make-flight: Keep using buster for L2 guest in nested tests Anthony PERARD
2024-03-20 17:24   ` Roger Pau Monné
2024-03-26 12:36     ` Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 34/36] Temporally switch "qemu-mainline" branch to Bookworm Anthony PERARD
2024-03-20 17:25   ` Roger Pau Monné
2024-03-26 12:30     ` Anthony PERARD
2024-03-18 16:55 ` [OSSTEST PATCH 35/36] Switch to Debian Bookworm as default suite Anthony PERARD
2024-03-20 17:26   ` Roger Pau Monné
2024-03-18 16:55 ` [OSSTEST PATCH 36/36] make-hosts-flight: default to bookworm Anthony PERARD
2024-03-20 17:28 ` [OSSTEST PATCH 00/36] Switch to Debian Bookworm Roger Pau Monné
2024-03-28 17:54 ` Anthony PERARD
2024-04-05 15:54   ` Anthony PERARD
2024-04-08  9:29     ` Anthony PERARD
2024-04-19  8:34       ` Anthony PERARD
2024-04-19  8:50         ` Roger Pau Monné
2024-04-02 10:08 ` [OSSTEST PATCH 37/36] production-config: Set Bookworm's debian-installer version Anthony PERARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240318165545.3898-15-anthony.perard@citrix.com \
    --to=anthony.perard@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.