]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: net_id - support predictable ifnames on virtio buses 1119/head
authorTom Gundersen <teg@jklm.no>
Tue, 25 Aug 2015 12:12:19 +0000 (14:12 +0200)
committerTom Gundersen <teg@jklm.no>
Wed, 2 Sep 2015 12:24:17 +0000 (14:24 +0200)
Virtio buses are undeterministically enumerated, so we cannot use them as a basis
for deterministic naming (see bf81e792f3c0). However, we are guaranteed that there
is only ever one virtio bus for every parent device, so we can simply skip over
the virtio buses when naming the devices.

src/udev/udev-builtin-net_id.c

index 6e7e1271fb64420e9d87fe9d47e3dc45ba60476d..589f1f7822609c9897ee199c11238b1806878180 100644 (file)
@@ -280,8 +280,16 @@ static int names_pci(struct udev_device *dev, struct netnames *names) {
         assert(names);
 
         parent = udev_device_get_parent(dev);
+
+        /* there can only ever be one virtio bus per parent device, so we can
+           safely ignore any virtio buses. see
+           <http://lists.linuxfoundation.org/pipermail/virtualization/2015-August/030331.html> */
+        while (parent && streq_ptr("virtio", udev_device_get_subsystem(parent)))
+                parent = udev_device_get_parent(parent);
+
         if (!parent)
                 return -ENOENT;
+
         /* check if our direct parent is a PCI device with no other bus in-between */
         if (streq_ptr("pci", udev_device_get_subsystem(parent))) {
                 names->type = NET_PCI;