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