daandemeyer / rpms / systemd

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