Blame SOURCES/0293-path_id-reintroduce-by-path-links-for-virtio-block-d.patch

17b0f1
From b6fea1a0e0fd830e1aa82accf389cb8bfd0f0f37 Mon Sep 17 00:00:00 2001
17b0f1
From: Michal Sekletar <msekleta@redhat.com>
17b0f1
Date: Tue, 9 Feb 2016 09:57:45 +0100
17b0f1
Subject: [PATCH] path_id: reintroduce by-path links for virtio block devices
17b0f1
17b0f1
Enumeration of virtio buses is global and hence
17b0f1
non-deterministic. However, we are guaranteed there is never going to be
17b0f1
more than one virtio bus per parent PCI device. While populating
17b0f1
ID_PATH we simply skip virtio part of the syspath and we extend the path
17b0f1
using the sysname of the parent PCI device.
17b0f1
17b0f1
With this patch udev creates following by-path links for virtio-blk
17b0f1
device /dev/vda which contains two partitions.
17b0f1
17b0f1
ls -l /dev/disk/by-path/
17b0f1
total 0
17b0f1
lrwxrwxrwx 1 root root  9 Feb  9 10:47 virtio-pci-0000:00:05.0 -> ../../vda
17b0f1
lrwxrwxrwx 1 root root 10 Feb  9 10:47 virtio-pci-0000:00:05.0-part1 -> ../../vda1
17b0f1
lrwxrwxrwx 1 root root 10 Feb  9 10:47 virtio-pci-0000:00:05.0-part2 -> ../../vda2
17b0f1
17b0f1
See:
17b0f1
http://lists.linuxfoundation.org/pipermail/virtualization/2015-August/030328.html
17b0f1
17b0f1
Fixes #2501
17b0f1
17b0f1
Cherry-picked from: f073b1b3c0f4f0df1b0bd61042ce85fb5d27d407
17b0f1
Resolves: #952567
17b0f1
---
17b0f1
 src/udev/udev-builtin-path_id.c | 6 ++++++
17b0f1
 1 file changed, 6 insertions(+)
17b0f1
17b0f1
diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c
17b0f1
index 3b72922d48..8359e236a1 100644
17b0f1
--- a/src/udev/udev-builtin-path_id.c
17b0f1
+++ b/src/udev/udev-builtin-path_id.c
17b0f1
@@ -698,6 +698,12 @@ restart:
17b0f1
                         path_prepend(&path, "xen-%s", udev_device_get_sysname(parent));
17b0f1
                         parent = skip_subsystem(parent, "xen");
17b0f1
                         supported_parent = true;
17b0f1
+                } else if (streq(subsys, "virtio")) {
17b0f1
+                        while (parent && streq_ptr("virtio", udev_device_get_subsystem(parent)))
17b0f1
+                                parent = udev_device_get_parent(parent);
17b0f1
+                        path_prepend(&path, "virtio-pci-%s", udev_device_get_sysname(parent));
17b0f1
+                        supported_transport = true;
17b0f1
+                        supported_parent = true;
17b0f1
                 } else if (streq(subsys, "scm")) {
17b0f1
                         path_prepend(&path, "scm-%s", udev_device_get_sysname(parent));
17b0f1
                         parent = skip_subsystem(parent, "scm");