daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
923a60
From bd1bb4504d1afe264fd3f739614b97aac8d62bf0 Mon Sep 17 00:00:00 2001
923a60
From: Tom Gundersen <teg@jklm.no>
923a60
Date: Tue, 25 Aug 2015 14:12:19 +0200
923a60
Subject: [PATCH] udev: net_id - support predictable ifnames on virtio buses
923a60
923a60
Virtio buses are undeterministically enumerated, so we cannot use them as a basis
923a60
for deterministic naming (see bf81e792f3c0). However, we are guaranteed that there
923a60
is only ever one virtio bus for every parent device, so we can simply skip over
923a60
the virtio buses when naming the devices.
923a60
923a60
Cherry-picked from: 54683f0f9b97a8f88aaf4fbb45b4d729057b101c
923a60
Resolves: #1259015
923a60
---
923a60
 src/udev/udev-builtin-net_id.c | 8 ++++++++
923a60
 1 file changed, 8 insertions(+)
923a60
923a60
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
923a60
index dd2886caf2..ddd83d4f1b 100644
923a60
--- a/src/udev/udev-builtin-net_id.c
923a60
+++ b/src/udev/udev-builtin-net_id.c
923a60
@@ -283,8 +283,16 @@ static int names_pci(struct udev_device *dev, struct netnames *names) {
923a60
         struct udev_device *parent;
923a60
 
923a60
         parent = udev_device_get_parent(dev);
923a60
+
923a60
+        /* there can only ever be one virtio bus per parent device, so we can
923a60
+           safely ignore any virtio buses. see
923a60
+           <http://lists.linuxfoundation.org/pipermail/virtualization/2015-August/030331.html> */
923a60
+        while (parent && streq_ptr("virtio", udev_device_get_subsystem(parent)))
923a60
+                parent = udev_device_get_parent(parent);
923a60
+
923a60
         if (!parent)
923a60
                 return -ENOENT;
923a60
+
923a60
         /* check if our direct parent is a PCI device with no other bus in-between */
923a60
         if (streq_ptr("pci", udev_device_get_subsystem(parent))) {
923a60
                 names->type = NET_PCI;