daandemeyer / rpms / systemd

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