Bug#860246: [PATCH] ubuntu: udev.postinst preserve virtio interfaces names on upgrades, on s390x.
Dimitri John Ledkov
xnox at ubuntu.com
Fri Apr 21 13:56:43 BST 2017
New udev generates stable interface names on s390x kvm instances, however, upon
upgrades existing ethX names should be preserved to prevent breaking networking
and software configurations.
This patch only affects Ubuntu systems.
Closes: #860246
LP: #1682437
---
Hi,
This did end up being critical for z/KVM and Ubuntu KVM guests upgrades from
yakkety to zesty. This is now applied in zesty. Looking forward, this is the
only non-upstream change in Ubuntu right now, and we will need to carry this
for another year.
I have now adjusted the patch, such that it only affects Ubuntu. Would you be
ok to apply this updated patch to the master branch targeting experimental /
next ubuntu release?
Answers to code review questions:
- on ubuntu, systemd is in minimal and thus systemd-detect-virt is available.
- /usr/lib/udev does not exist by default, and it was not deemed important
enough to be in /lib (as this is only run during upgrades), thus we settled
for any existing /usr/share used by systemd*, there appear to be a handful
of auxiliary files in /usr/share/systemd already.
Regards,
Dimiti.
debian/extra/write_persistent_net_s390x_virtio | 40 ++++++++++++++++++++++++++
debian/rules | 1 +
debian/udev.postinst | 8 ++++++
3 files changed, 49 insertions(+)
create mode 100755 debian/extra/write_persistent_net_s390x_virtio
diff --git a/debian/extra/write_persistent_net_s390x_virtio b/debian/extra/write_persistent_net_s390x_virtio
new file mode 100755
index 0000000..bbeb250
--- /dev/null
+++ b/debian/extra/write_persistent_net_s390x_virtio
@@ -0,0 +1,40 @@
+#!/bin/sh
+set -e
+
+#
+# udevd since 232-20 learned to generate stable interface names for network
+# interfaces in kvm/qemu. However, existing machines upgrading will be using
+# the ethX names instead. The most risk-averse action is to encode
+# "persistent-net-rules" like rules to keep the ethX names on upgrades, since
+# the interface names (ethX) may be in use not only in /etc/network/interfaces
+# but in other configurations too (daemons, firewalls, etc).
+#
+# This is a one time action, and can be removed after the next stable & LTS
+# releases. (~ May 2018)
+#
+
+rulesfile=/etc/udev/rules.d/70-persistent-net.rules
+
+if [ `uname -m` != 's390x' ]
+then
+ exit 0
+fi
+
+if [ `systemd-detect-virt` != 'kvm' ]
+then
+ exit 0
+fi
+
+if [ -f $rulesfile ]
+then
+ exit 0
+fi
+
+for interface in /sys/class/net/eth*
+do
+ name=$(basename $interface)
+ address=$(cat $interface/address)
+ cat <<EOF >>$rulesfile
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="$address", KERNEL=="eth*", NAME="$name"
+EOF
+done
diff --git a/debian/rules b/debian/rules
index 00d679e..d3112e5 100755
--- a/debian/rules
+++ b/debian/rules
@@ -313,6 +313,7 @@ ifeq ($(DEB_VENDOR),Ubuntu)
install --mode=644 debian/extra/rules-ubuntu/*.rules debian/udev/lib/udev/rules.d/
cp -a debian/extra/units-ubuntu/* debian/systemd/lib/systemd/system/
install --mode=755 debian/extra/set-cpufreq debian/systemd/lib/systemd/
+ install --mode=755 debian/extra/write_persistent_net_s390x_virtio debian/udev/usr/share/systemd/
endif
override_dh_installinit:
diff --git a/debian/udev.postinst b/debian/udev.postinst
index beaabb9..10db5b6 100644
--- a/debian/udev.postinst
+++ b/debian/udev.postinst
@@ -85,6 +85,14 @@ Driver=virtio_net
NamePolicy=onboard kernel
EOF
fi
+
+ # 232-20 (232-21ubuntu3 in ubuntu) introduced predicable interface names on
+ # s390x for virtio However, we should preserve ethX names on upgrade.
+ if [ -x /usr/share/systemd/write_persistent_net_s390x_virtio ]; then
+ if dpkg --compare-versions "$2" lt-nl "232-21ubuntu3~"; then
+ /usr/share/systemd/write_persistent_net_s390x_virtio || true
+ fi
+ fi
}
update_hwdb() {
--
2.7.4
More information about the Pkg-systemd-maintainers
mailing list